Index: /home/mmillson/workspace/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java =================================================================== --- /home/mmillson/workspace/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java (revision 78967) +++ /home/mmillson/workspace/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java (working copy) @@ -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"); - - TimerServiceImpl timerService = (TimerServiceImpl)entry.getValue(); - Collection col = timerService.getAllTimers(); - for (Iterator iterator = col.iterator(); iterator.hasNext();) + Iterator it = timerServiceMap.entrySet().iterator(); + while (it.hasNext()) { - TimerImpl timer = (TimerImpl)iterator.next(); - TimerHandleImpl handle = new TimerHandleImpl(timer); - retBuffer.append(" handle: " + handle + "\n"); - retBuffer.append(" " + timer + "\n"); + 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"); + } } } return retBuffer.toString(); - } - + } }