[jboss-jira] [JBoss JIRA] Resolved: (EJBTHREE-1501) Operations on cacheMap are not thread safe

Galder Zamarreno (JIRA) jira-events at lists.jboss.org
Fri Sep 26 05:19:20 EDT 2008


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

Galder Zamarreno resolved EJBTHREE-1501.
----------------------------------------

    Resolution: Cannot Reproduce Bug


We don't have a valid use case for fixing this.

> Operations on cacheMap are not thread safe
> ------------------------------------------
>
>                 Key: EJBTHREE-1501
>                 URL: https://jira.jboss.org/jira/browse/EJBTHREE-1501
>             Project: EJB 3.0
>          Issue Type: Sub-task
>    Affects Versions: AS 4.2.3.GA, 1.0.0-Beta3
>            Reporter: Galder Zamarreno
>            Assignee: Galder Zamarreno
>
> Finally, code like this is not thread safe:
>       synchronized (cacheMap)
>       {
>          ctx = (StatefulBeanContext) cacheMap.get(key);
>       }
>       if(ctx == null)
>          throw new NoSuchEJBException("Could not find Stateful bean: " + key);
>       if (!ctx.isRemoved())
>          container.destroy(ctx);
>       
>       ++removeCount;
>       
>       if (ctx.getCanRemoveFromCache())
>       {
>          synchronized (cacheMap)
>          {
>             cacheMap.remove(key);
>          }
>       }
> This is essentiall a removeIfPresent type of operation on cacheMap and hence 
> get() and remove() operation, as they depend on each other, should be in a 
> single synchronized statement. Example:
>       synchronized (cacheMap)
>       {
>          ctx = (StatefulBeanContext) cacheMap.get(key);
>          if(ctx == null)
>             throw new NoSuchEJBException("Could not find Stateful bean: " + key);
>          if (!ctx.isRemoved())
>             container.destroy(ctx);
>       
>          ++removeCount;
>       
>          if (ctx.getCanRemoveFromCache())
>          {
>             cacheMap.remove(key);
>          }
>      }

-- 
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