[jboss-cvs] JBossAS SVN: r78918 - branches/Branch_4_2/server/src/main/org/jboss/ejb/txtimer.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Sep 29 05:41:08 EDT 2008
Author: alex.loubyansky at jboss.com
Date: 2008-09-29 05:41:08 -0400 (Mon, 29 Sep 2008)
New Revision: 78918
Modified:
branches/Branch_4_2/server/src/main/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
Log:
JBAS-5999 synchronize on timerServiceMap before iteration
Modified: branches/Branch_4_2/server/src/main/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
===================================================================
--- branches/Branch_4_2/server/src/main/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java 2008-09-29 09:37:51 UTC (rev 78917)
+++ branches/Branch_4_2/server/src/main/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java 2008-09-29 09:41:08 UTC (rev 78918)
@@ -341,17 +341,20 @@
public void removeTimerService(ObjectName containerId, boolean keepState) throws IllegalStateException
{
// remove all timers with the given containerId
- Iterator it = timerServiceMap.entrySet().iterator();
- while (it.hasNext())
+ synchronized(timerServiceMap)
{
- Map.Entry entry = (Map.Entry)it.next();
- TimedObjectId key = (TimedObjectId)entry.getKey();
- TimerServiceImpl timerService = (TimerServiceImpl)entry.getValue();
- if (containerId.equals(key.getContainerId()))
+ Iterator it = timerServiceMap.entrySet().iterator();
+ while (it.hasNext())
{
- log.debug("removeTimerService: " + timerService);
- timerService.shutdown(keepState);
- it.remove();
+ Map.Entry entry = (Map.Entry)it.next();
+ TimedObjectId key = (TimedObjectId)entry.getKey();
+ TimerServiceImpl timerService = (TimerServiceImpl)entry.getValue();
+ if (containerId.equals(key.getContainerId()))
+ {
+ log.debug("removeTimerService: " + timerService);
+ timerService.shutdown(keepState);
+ it.remove();
+ }
}
}
}
@@ -380,17 +383,20 @@
// remove all timers with the given containerId
else
{
- Iterator it = timerServiceMap.entrySet().iterator();
- while (it.hasNext())
+ synchronized(timerServiceMap)
{
- Map.Entry entry = (Map.Entry)it.next();
- TimedObjectId key = (TimedObjectId)entry.getKey();
- TimerServiceImpl timerService = (TimerServiceImpl)entry.getValue();
- if (containerId.equals(key.getContainerId()))
+ Iterator it = timerServiceMap.entrySet().iterator();
+ while (it.hasNext())
{
- log.debug("removeTimerService: " + timerService);
- timerService.shutdown(keepState);
- it.remove();
+ Map.Entry entry = (Map.Entry)it.next();
+ TimedObjectId key = (TimedObjectId)entry.getKey();
+ TimerServiceImpl timerService = (TimerServiceImpl)entry.getValue();
+ if (containerId.equals(key.getContainerId()))
+ {
+ log.debug("removeTimerService: " + timerService);
+ timerService.shutdown(keepState);
+ it.remove();
+ }
}
}
}
@@ -447,24 +453,26 @@
public String listTimers()
{
StringBuffer retBuffer = new StringBuffer();
- Iterator it = timerServiceMap.entrySet().iterator();
- while (it.hasNext())
+ synchronized(timerServiceMap)
{
- Map.Entry entry = (Map.Entry)it.next();
- TimedObjectId timedObjectId = (TimedObjectId)entry.getKey();
- retBuffer.append(timedObjectId + "\n");
+ Iterator it = timerServiceMap.entrySet().iterator();
+ while (it.hasNext())
+ {
+ Map.Entry entry = (Map.Entry)it.next();
+ TimedObjectId timedObjectId = (TimedObjectId)entry.getKey();
+ retBuffer.append(timedObjectId + "\n");
- TimerServiceImpl timerService = (TimerServiceImpl)entry.getValue();
- Collection col = timerService.getAllTimers();
- for (Iterator iterator = col.iterator(); iterator.hasNext();)
- {
- TimerImpl timer = (TimerImpl)iterator.next();
- TimerHandleImpl handle = new TimerHandleImpl(timer);
- retBuffer.append(" handle: " + handle + "\n");
- retBuffer.append(" " + timer + "\n");
+ TimerServiceImpl timerService = (TimerServiceImpl)entry.getValue();
+ Collection col = timerService.getAllTimers();
+ for (Iterator iterator = col.iterator(); iterator.hasNext();)
+ {
+ TimerImpl timer = (TimerImpl)iterator.next();
+ TimerHandleImpl handle = new TimerHandleImpl(timer);
+ retBuffer.append(" handle: " + handle + "\n");
+ retBuffer.append(" " + timer + "\n");
+ }
}
}
return retBuffer.toString();
- }
-
+ }
}
More information about the jboss-cvs-commits
mailing list