Author: manik.surtani(a)jboss.com
Date: 2008-01-15 05:40:11 -0500 (Tue, 15 Jan 2008)
New Revision: 5132
Modified:
core/trunk/src/main/java/org/jboss/cache/config/Option.java
core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
core/trunk/src/test/java/org/jboss/cache/options/cachemodelocal/CacheModeLocalTestBase.java
Log:
JBCACHE-1263 Node.addChild() local mode suppression
Modified: core/trunk/src/main/java/org/jboss/cache/config/Option.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/Option.java 2008-01-15 05:17:56 UTC
(rev 5131)
+++ core/trunk/src/main/java/org/jboss/cache/config/Option.java 2008-01-15 10:40:11 UTC
(rev 5132)
@@ -238,21 +238,29 @@
public String toString()
{
return "Option{" +
- "failSilently=" + failSilently +
- ", cacheModeLocal=" + cacheModeLocal +
- ", dataVersion=" + dataVersion +
- ", suppressLocking=" + suppressLocking +
- ", lockAcquisitionTimeout=" + lockAcquisitionTimeout +
- ", forceDataGravitation=" + forceDataGravitation +
- ", skipDataGravitation=" + skipDataGravitation +
- ", forceAsynchronous=" + forceAsynchronous +
- ", forceSynchronous=" + forceSynchronous +
- '}';
+ "failSilently=" + failSilently +
+ ", cacheModeLocal=" + cacheModeLocal +
+ ", dataVersion=" + dataVersion +
+ ", suppressLocking=" + suppressLocking +
+ ", lockAcquisitionTimeout=" + lockAcquisitionTimeout +
+ ", forceDataGravitation=" + forceDataGravitation +
+ ", skipDataGravitation=" + skipDataGravitation +
+ ", forceAsynchronous=" + forceAsynchronous +
+ ", forceSynchronous=" + forceSynchronous +
+ '}';
}
- public Option clone() throws CloneNotSupportedException
+ public Option clone()
{
- return (Option) super.clone();
+ try
+ {
+ return (Option) super.clone();
+ }
+ catch (CloneNotSupportedException e)
+ {
+ // should never happen!
+ throw new RuntimeException(e);
+ }
}
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java 2008-01-15
05:17:56 UTC (rev 5131)
+++
core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java 2008-01-15
10:40:11 UTC (rev 5132)
@@ -6,6 +6,7 @@
import org.jboss.cache.NodeNotValidException;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.UnversionedNode;
+import org.jboss.cache.config.Option;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.lock.NodeLock;
import org.jboss.cache.optimistic.DataVersion;
@@ -273,10 +274,16 @@
// TODO: Revisit. Is this really threadsafe? See comment in putIfAbsent() - same
solution should be applied here too.
assertValid();
Fqn nf = new Fqn(getFqn(), f);
+ Option o1 = spi.getInvocationContext().getOptionOverrides().clone();
Node<K, V> child = getChild(f);
+
if (child == null)
{
+ Option o2 = o1.clone();
+ spi.getInvocationContext().setOptionOverrides(o1);
spi.put(nf, null);
+
+ spi.getInvocationContext().setOptionOverrides(o2);
child = getChild(f);
}
return child;
Modified:
core/trunk/src/test/java/org/jboss/cache/options/cachemodelocal/CacheModeLocalTestBase.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/options/cachemodelocal/CacheModeLocalTestBase.java 2008-01-15
05:17:56 UTC (rev 5131)
+++
core/trunk/src/test/java/org/jboss/cache/options/cachemodelocal/CacheModeLocalTestBase.java 2008-01-15
10:40:11 UTC (rev 5132)
@@ -12,9 +12,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.config.Configuration;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNull;
-import static org.testng.AssertJUnit.assertTrue;
+import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -188,8 +186,9 @@
}
// now cache2
- Node node2 = cache2.getRoot().getChild(fqn);
cache2.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
+ Node node2 = cache2.getRoot().addChild(fqn);
+ cache2.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
node2.put(key, "value2");
delay();
assertEquals("value2", cache2.get(fqn, key));
@@ -291,7 +290,8 @@
}
// now cache2
- Node node2 = cache2.getRoot().getChild(fqn);
+ cache2.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
+ Node node2 = cache2.getRoot().addChild(fqn);
map.put(key, "value2");
cache2.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
node2.putAll(map);
Show replies by date