[jbosscache-commits] JBoss Cache SVN: r7641 - in core/trunk/src: main/java/org/jboss/cache/interceptors and 1 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Wed Feb 4 11:28:37 EST 2009


Author: manik.surtani at jboss.com
Date: 2009-02-04 11:28:37 -0500 (Wed, 04 Feb 2009)
New Revision: 7641

Modified:
   core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java
   core/trunk/src/test/java/org/jboss/cache/commands/write/EvictCommandTest.java
Log:
JBCACHE-1473 -  Cache Regions lose capacity - EvictCommand.perform() causes dead entries in EvictionQueue (contributed by Roberto Tyley)

Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java	2009-02-04 16:08:50 UTC (rev 7640)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java	2009-02-04 16:28:37 UTC (rev 7641)
@@ -86,17 +86,13 @@
     * See {@link org.jboss.cache.interceptors.EvictionInterceptor#visitEvictFqnCommand(org.jboss.cache.InvocationContext , EvictCommand)}
     * which is where the return value is used
     *
-    * @return true if the node was removed from the tree or if it is resident.  Returns false if the node still exists; i.e. was only data removed because it still has children.
+    * @return true if the node is now absent from the cache.  Returns false if the node still exists; i.e. was only data removed because it still has children.
     */
    public Object perform(InvocationContext ctx)
    {
       NodeSPI node = lookupForEviction(ctx, fqn);
-      if (node == null || node.isDeleted())
+      if (node == null || node.isDeleted() || node.isResident())
       {
-         return false;
-      }
-      else if (node.isResident())
-      {
          return true;
       }
       else if (recursive)

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java	2009-02-04 16:08:50 UTC (rev 7640)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java	2009-02-04 16:28:37 UTC (rev 7641)
@@ -81,8 +81,8 @@
       // See if the node still exists; i.e. was only data removed
       // because it still has children.
       // If yes, put an ADD event in the queue so the node gets revisited
-      boolean complete = (retVal != null && (Boolean) retVal);
-      if (!complete)
+      boolean nodeIsNowAbsent = (retVal != null && (Boolean) retVal);
+      if (!nodeIsNowAbsent)
       {
          Region r;
          if (fqn != null && (r = getRegion(fqn)) != null)
@@ -244,10 +244,10 @@
    private void registerEvictionEventToRegionManager(Fqn fqn, EvictionEvent.Type type, int elementDifference, Region region)
    {
       //we do not trigger eviction events for resident nodes
-      if (dataContainer.isResident(fqn)) 
+      if (dataContainer.isResident(fqn))
       {
-        if (trace) log.trace("Ignoring Fqn " + fqn + " as it is marked as resident");	
-	return;
+         if (trace) log.trace("Ignoring Fqn " + fqn + " as it is marked as resident");
+         return;
       }
       region.registerEvictionEvent(fqn, type, elementDifference);
 

Modified: core/trunk/src/test/java/org/jboss/cache/commands/write/EvictCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/write/EvictCommandTest.java	2009-02-04 16:08:50 UTC (rev 7640)
+++ core/trunk/src/test/java/org/jboss/cache/commands/write/EvictCommandTest.java	2009-02-04 16:28:37 UTC (rev 7641)
@@ -47,6 +47,14 @@
       control.verify();
    }
 
+   public void testShouldReturnTrueIndicatingNodeIsAbsentIfNodeDoesntExist()
+   {
+      expect(container.peek(testFqn, false, true)).andReturn(null);
+      control.replay();
+      assert Boolean.TRUE == command.perform(ctx);
+      control.verify();
+   }
+
    public void testSimpleEviction()
    {
       expect(container.peek(testFqn, false, true)).andReturn(nodes.abNode);




More information about the jbosscache-commits mailing list