Author: mircea.markus
Date: 2008-08-27 08:34:27 -0400 (Wed, 27 Aug 2008)
New Revision: 6625
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/read/ExistsCommand.java
core/trunk/src/test/java/org/jboss/cache/commands/StructuralNodesOnRollbackTest.java
Log:
exist command should also look into the InvocationContext, as the node might be only in
the transaction context
Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/ExistsCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/read/ExistsCommand.java 2008-08-27
12:32:37 UTC (rev 6624)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/ExistsCommand.java 2008-08-27
12:34:27 UTC (rev 6625)
@@ -2,6 +2,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
+import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
/**
@@ -40,8 +41,8 @@
*/
public Object perform(InvocationContext ctx)
{
- // this command will use the data container directly since it does not require any
form of locking.
- return dataContainer.exists(fqn);
+ NodeSPI node = ctx.lookUpNode(fqn);
+ return node != null && !node.isDeleted();
}
public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
Modified:
core/trunk/src/test/java/org/jboss/cache/commands/StructuralNodesOnRollbackTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/commands/StructuralNodesOnRollbackTest.java 2008-08-27
12:32:37 UTC (rev 6624)
+++
core/trunk/src/test/java/org/jboss/cache/commands/StructuralNodesOnRollbackTest.java 2008-08-27
12:34:27 UTC (rev 6625)
@@ -2,6 +2,8 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.util.TestingUtil;
@@ -28,8 +30,7 @@
public void setUp()
{
Configuration cacheConfig =
UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL,
false);
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object,
Object>().createCache(cacheConfig, false);
- cache.start();
+ cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object,
Object>().createCache(cacheConfig);
txMgr = cache.getTransactionManager();
}
@@ -39,6 +40,17 @@
TestingUtil.killCaches(cache);
}
+ public void testNoTx() throws Exception
+ {
+ txMgr.begin();
+ cache.put("/a/b/c", "k","v");
+ NodeSPI<Object,Object> root = cache.getRoot();
+ assert root.getChild("a") != null;
+ assert root.getChild(Fqn.fromString("/a/b/c")) != null;
+ assert cache.exists("/a/b");
+ txMgr.rollback();
+ }
+
public void testPutDataMap() throws Exception
{
HashMap map = new HashMap();