[jboss-jira] [JBoss JIRA] Closed: (JBAS-5999) EJBTimerServiceImpl timerServiceMap access should be synchronized

Alexey Loubyansky (JIRA) jira-events at lists.jboss.org
Mon Sep 29 05:43:21 EDT 2008


     [ https://jira.jboss.org/jira/browse/JBAS-5999?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexey Loubyansky closed JBAS-5999.
-----------------------------------

    Fix Version/s: JBossAS-5.0.0.GA
                   JBossAS-4.2.4.GA
       Resolution: Done


Fixed. Thanks.

> EJBTimerServiceImpl timerServiceMap access should be synchronized
> -----------------------------------------------------------------
>
>                 Key: JBAS-5999
>                 URL: https://jira.jboss.org/jira/browse/JBAS-5999
>             Project: JBoss Application Server
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: EJB2
>    Affects Versions: JBossAS-4.2.3.GA, JBossAS-5.0.0.CR2
>            Reporter: Mike Millson
>            Assignee: Alexey Loubyansky
>             Fix For: JBossAS-5.0.0.GA, JBossAS-4.2.4.GA
>
>
> 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 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list