• Icon: Sub-task Sub-task
    • Resolution: Cannot Reproduce
    • Icon: Major 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)

      { 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); }

      }

            rh-ee-galder Galder ZamarreƱo
            rh-ee-galder Galder ZamarreƱo
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: