-
Sub-task
-
Resolution: Cannot Reproduce
-
Major
-
None
-
AS 4.2.3.GA, 1.0.0-Beta3
-
None
-
None
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)
}
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); }
}