Bug 1017673
Summary: | ConcurrentModificationException in TimerService.getTimers() | ||||||
---|---|---|---|---|---|---|---|
Product: | [JBoss] JBoss Enterprise Application Platform 6 | Reporter: | Jan Martiska <jmartisk> | ||||
Component: | EJB | Assignee: | Jan Martiska <jmartisk> | ||||
Status: | CLOSED CURRENTRELEASE | QA Contact: | Jan Martiska <jmartisk> | ||||
Severity: | medium | Docs Contact: | Russell Dickenson <rdickens> | ||||
Priority: | unspecified | ||||||
Version: | 6.2.0 | CC: | david.lloyd, jmartisk, kkhan, lcosti | ||||
Target Milestone: | DR0 | ||||||
Target Release: | EAP 6.3.0 | ||||||
Hardware: | Unspecified | ||||||
OS: | Unspecified | ||||||
Whiteboard: | |||||||
Fixed In Version: | Doc Type: | Bug Fix | |||||
Doc Text: |
If a bean attempted to create a new timer at the same time as another thread was calling the `getTimers()` method, a `ConcurrentModificationException` was thrown. This occurred because the `getTimers()` method did not call `synchronized()` on the timers.
This issue is fixed in this release, and the timer service implementation's `getTimers()` method now properly calls `synchronized()` on the timers.
|
Story Points: | --- | ||||
Clone Of: | Environment: | ||||||
Last Closed: | 2014-06-28 15:44:52 UTC | Type: | Bug | ||||
Regression: | --- | Mount Type: | --- | ||||
Documentation: | --- | CRM: | |||||
Verified Versions: | Category: | --- | |||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
Cloudforms Team: | --- | Target Upstream Version: | |||||
Embargoed: | |||||||
Attachments: |
|
Assigning jpai EJB issues to david.lloyd. Please re-assign to Cheng or others as needed. Going to fix this myself. Can't reproduce on upstream, it seems it was fixed there earlier with commit 7a4541f6. The pull request looks OK so I'm devel_ack+ this. Fixed in 6.3.0.DR0. |
Created attachment 810437 [details] reproducer The implementation of org.jboss.as.ejb3.timerservice.TimerService.getTimers() iterates over three collections (activePersistentTimers, persistentWaitingOnTxCompletionTimers, nonPersistentTimers) using a for-each loop without synchronizing on them. This can lead to a ConcurrentModificationException if a bean is creating a timer and at the same time another thread is calling getTimers(). Reproducer mimicking this scenario is attached. Just deploy it to a running EAP instance. A Singleton bean will create/remove lots of timers and at the same time another thread will call getTimers repeatedly. Expected outcome: it deploys successfully and says "No ConcurrentModificationException encountered" Actual outcome - after some time: java.util.ConcurrentModificationException at java.util.HashMap$HashIterator.nextEntry(HashMap.java:894) [rt.jar:1.7.0_25] at java.util.HashMap$ValueIterator.next(HashMap.java:922) [rt.jar:1.7.0_25] at org.jboss.as.ejb3.timerservice.TimerServiceImpl.getTimers(TimerServiceImpl.java:372) at TimerGenerator.getTimers(TimerGenerator.java:63) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_25] (....)