[jboss-cvs] JBossAS SVN: r70806 - in projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache: simple and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Mar 13 05:35:51 EDT 2008


Author: wolfc
Date: 2008-03-13 05:35:50 -0400 (Thu, 13 Mar 2008)
New Revision: 70806

Modified:
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/NoPassivationCache.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/simple/SimpleStatefulCache.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/tree/StatefulTreeCache.java
Log:
EJBTHREE-1218: throw NoSuchEJBException on remove non-existent

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/NoPassivationCache.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/NoPassivationCache.java	2008-03-13 09:34:38 UTC (rev 70805)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/NoPassivationCache.java	2008-03-13 09:35:50 UTC (rev 70806)
@@ -147,11 +147,10 @@
       {
          ctx = (StatefulBeanContext) cacheMap.remove(key);
       }
-      if (ctx != null)
-      {
-         pool.remove(ctx);
-         ++removeCount;
-      }
+      if(ctx == null)
+         throw new NoSuchEJBException("Could not find Stateful bean: " + key);
+      pool.remove(ctx);
+      ++removeCount;
    }
 
    public int getCacheSize()

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/simple/SimpleStatefulCache.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/simple/SimpleStatefulCache.java	2008-03-13 09:34:38 UTC (rev 70805)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/simple/SimpleStatefulCache.java	2008-03-13 09:35:50 UTC (rev 70806)
@@ -451,23 +451,20 @@
       {
          ctx = (StatefulBeanContext) cacheMap.get(key);
       }
-      if (ctx != null) 
+      if(ctx == null)
+         throw new NoSuchEJBException("Could not find Stateful bean: " + key);
+      if (!ctx.isRemoved())
+         pool.remove(ctx);
+      
+      ++removeCount;
+      
+      if (ctx.getCanRemoveFromCache())
       {
-         if (!ctx.isRemoved())
-            pool.remove(ctx);
-         
-         ++removeCount;
-         
-         if (ctx.getCanRemoveFromCache())
+         synchronized (cacheMap)
          {
-            synchronized (cacheMap)
-            {
-               cacheMap.remove(key);
-            }
+            cacheMap.remove(key);
          }
       }
-//      else
-//         log.warn("Remove failed, context " + key + " was not found");
    }
 
    public int getCacheSize()

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/tree/StatefulTreeCache.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/tree/StatefulTreeCache.java	2008-03-13 09:34:38 UTC (rev 70805)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/cache/tree/StatefulTreeCache.java	2008-03-13 09:35:50 UTC (rev 70806)
@@ -235,27 +235,27 @@
          InvocationContext ictx = cache.getInvocationContext();
          ictx.setOptionOverrides(getGravitateOption());
          StatefulBeanContext ctx = (StatefulBeanContext) cache.get(id, "bean");
+         
+         if(ctx == null)
+            throw new NoSuchEJBException("Could not find Stateful bean: " + key);
+         
+         if (!ctx.isRemoved())
+            pool.remove(ctx);
 
-         if (ctx != null)
+         if (ctx.getCanRemoveFromCache())
          {
-            if (!ctx.isRemoved())
-               pool.remove(ctx);
+            // Do a cluster-wide removal of the ctx
+            cache.removeNode(id);
+         }
+         else
+         {
+            // We can't remove the ctx as it contains live nested beans
+            // But, we must replicate it so other nodes know the parent is removed!
+            putInCache(ctx);
+         }
 
-            if (ctx.getCanRemoveFromCache())
-            {
-               // Do a cluster-wide removal of the ctx
-               cache.removeNode(id);
-            }
-            else
-            {
-               // We can't remove the ctx as it contains live nested beans
-               // But, we must replicate it so other nodes know the parent is removed!
-               putInCache(ctx);
-            }
-
-            ++removeCount;
-            beans.remove(key);
-         }
+         ++removeCount;
+         beans.remove(key);
       }
       catch (CacheException e)
       {




More information about the jboss-cvs-commits mailing list