Uploaded image for project: 'JBoss Enterprise Application Platform 4 and 5'
  1. JBoss Enterprise Application Platform 4 and 5
  2. JBPAPP-1227

JBAS-5999 - EJBTimerServiceImpl timerServiceMap access should be synchronized

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Done
    • Icon: Blocker Blocker
    • 4.2.0.GA_CP05, 4.3.0.GA_CP03
    • None
    • EJB
    • None
    • Release Notes

      The timerServiceMap in org.jboss.ejb.txtimer.EJBTimerServiceImpl should be synchronized[1].

      Original code: // Maps the timedObjectId to TimerServiceImpl objects
      private Map timerServiceMap = Collections.synchronizedMap(new HashMap());

      public void removeTimerService(ObjectName containerId, boolean keepState) throws IllegalStateException
      {
      // remove all timers with the given containerId
      Iterator it = timerServiceMap.entrySet().iterator();
      while (it.hasNext())
      {
      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(); }

      }
      }

      Fixed:
      public void removeTimerService(ObjectName containerId, boolean keepState) throws IllegalStateException
      {
      // remove all timers with the given containerId
      synchronized(timerServiceMap)
      {
      Iterator it = timerServiceMap.entrySet().iterator();
      while (it.hasNext())
      {
      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(); }

      }
      }
      }

      [1]http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collections.html#synchronizedMap(java.util.Map

              rhn-support-mmillson Michael Millson
              rhn-support-mmillson Michael Millson
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: