[jbosscache-commits] JBoss Cache SVN: r8395 - in core/trunk/src: test/java/org/jboss/cache/api/mvcc/repeatable_read and 1 other directory.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Thu Apr 22 06:37:09 EDT 2010


Author: galder.zamarreno at jboss.com
Date: 2010-04-22 06:37:08 -0400 (Thu, 22 Apr 2010)
New Revision: 8395

Modified:
   core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
   core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/CacheAPIMVCCTest.java
Log:
[JBCACHE-1579] (NPE on some operations after calling removeNode on an unexistent FQN) Fixed.

Modified: core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java	2010-04-22 10:34:34 UTC (rev 8394)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java	2010-04-22 10:37:08 UTC (rev 8395)
@@ -215,7 +215,11 @@
 
    public V removeDirect(K key)
    {
-      return node.remove(key);
+      if (node != null) {
+         return node.remove(key);
+      } else {
+         return null;
+      }      
    }
 
    public V putDirect(K key, V value)
@@ -240,7 +244,7 @@
 
    public void clearDataDirect()
    {
-      node.clear();
+      if (node != null) node.clear();
    }
 
    public boolean containsKeyDirect(K key) {

Modified: core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/CacheAPIMVCCTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/CacheAPIMVCCTest.java	2010-04-22 10:34:34 UTC (rev 8394)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/CacheAPIMVCCTest.java	2010-04-22 10:37:08 UTC (rev 8395)
@@ -1,5 +1,6 @@
 package org.jboss.cache.api.mvcc.repeatable_read;
 
+import org.jboss.cache.Fqn;
 import org.jboss.cache.api.CacheAPITest;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.config.Configuration.NodeLockingScheme;
@@ -42,4 +43,58 @@
       tx.commit();
       assert cache.getNode("/a") == null; // this fails
    }
+
+   public void testRemoveAndOperateOnUnexistingNode() throws Exception
+   {
+      TransactionManager tm = cache.getTransactionManager();
+      tm.begin();
+      cache.removeNode("/a");
+      cache.clearData("/a");
+      tm.commit();
+      assert cache.getNode("/a") == null; // this fails
+
+      tm.begin();
+      cache.removeNode("/a");
+      cache.getNode("/a");
+      tm.commit();
+      assert cache.getNode("/a") == null; // this fails
+
+      tm.begin();
+      cache.removeNode("/a");
+      cache.get("/a", "boo");
+      tm.commit();
+      assert cache.getNode("/a") == null; // this fails
+
+      tm.begin();
+      cache.removeNode("/a");
+      cache.remove("/a", "boo");
+      tm.commit();
+      assert cache.getNode("/a") == null; // this fails
+
+      tm.begin();
+      cache.removeNode("/a");
+      cache.evict(Fqn.fromString("/a"));
+      tm.commit();
+      assert cache.getNode("/a") == null; // this fails
+
+      tm.begin();
+      cache.removeNode("/a");
+      cache.evict(Fqn.fromString("/a"));
+      tm.commit();
+      assert cache.getNode("/a") == null; // this fails
+
+      tm.begin();
+      cache.removeNode("/a");
+      cache.move("/a", "/b");
+      tm.commit();
+      assert cache.getNode("/a") == null; // this fails
+
+      tm.begin();
+      cache.removeNode("/a");
+      cache.removeRegion(Fqn.fromString("/a"));
+      tm.commit();
+      assert cache.getNode("/a") == null; // this fails
+
+   }
+
 }
\ No newline at end of file



More information about the jbosscache-commits mailing list