Author: manik.surtani(a)jboss.com
Date: 2008-03-05 12:19:14 -0500 (Wed, 05 Mar 2008)
New Revision: 5389
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java
core/trunk/src/test/java/org/jboss/cache/transaction/TransactionTest.java
Log:
JBCACHE-1296 - Also applies to data in undeleted nodes
JBCACHE-1294 - Double removal of a node may cause unintended resurrection
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java 2008-03-05
16:55:13 UTC (rev 5388)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java 2008-03-05
17:19:14 UTC (rev 5389)
@@ -96,6 +96,7 @@
protected void undeleteWorkspaceNode(WorkspaceNode nodeToUndelete, WorkspaceNode
parent)
{
nodeToUndelete.markAsDeleted(false);
+ nodeToUndelete.clearData();
// add in parent again
parent.addChild(nodeToUndelete);
nodeToUndelete.markAsResurrected(true);
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java 2008-03-05
16:55:13 UTC (rev 5388)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java 2008-03-05
17:19:14 UTC (rev 5389)
@@ -69,7 +69,7 @@
GlobalTransaction gtx = getGlobalTransaction(ctx);
TransactionWorkspace workspace = getTransactionWorkspace(gtx);
Fqn fqn = getFqn(args, m.getMethodId());
- WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, fqn, workspace, true,
true);
+ WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, fqn, workspace,
MethodDeclarations.removeNodeMethodLocal_id != m.getMethodId(), true);
// in the case of a data gravitation cleanup, if the primary Fqn does not exist
the backup one may.
if (workspaceNode == null && m.getMethodId() ==
MethodDeclarations.dataGravitationCleanupMethod_id)
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-03-05
16:55:13 UTC (rev 5388)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-03-05
17:19:14 UTC (rev 5389)
@@ -628,6 +628,7 @@
if (gtx != null && needToReverseRemove)
{
childNode.markAsDeleted(false);
+ childNode.clearDataDirect();
if (createdNodes != null)
{
createdNodes.add(childNode);
Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java 2008-03-05 16:55:13 UTC
(rev 5388)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java 2008-03-05 17:19:14 UTC
(rev 5389)
@@ -111,7 +111,20 @@
tm.commit();
}
+ public void testOverwritingDataTx() throws Exception
+ {
+ Node<Object, Object> nodeA = rootNode.addChild(A);
+ nodeA.put("key", "value");
+ assertEquals("value", nodeA.get("key"));
+ tm.begin();
+ rootNode.removeChild(A);
+ cache.put(A, "k2", "v2");
+ tm.commit();
+ assertNull(nodeA.get("key"));
+ assertEquals("v2", nodeA.get("k2"));
+ }
+
/**
* Remember, Fqns are relative!!
*/
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/TransactionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/TransactionTest.java 2008-03-05
16:55:13 UTC (rev 5388)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/TransactionTest.java 2008-03-05
17:19:14 UTC (rev 5389)
@@ -15,10 +15,8 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
-import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.lock.NodeLock;
-import org.jboss.cache.misc.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -45,7 +43,7 @@
@Test(groups = {"functional", "transaction"})
public class TransactionTest
{
- CacheSPI cache = null;
+ CacheSPI<String, Comparable> cache = null;
UserTransaction tx = null;
Exception thread_ex;
@@ -53,8 +51,8 @@
public void setUp() throws Exception
{
- CacheFactory<String, Comparable> instance = new DefaultCacheFactory();
- cache = (CacheSPI) instance.createCache(false);
+ CacheFactory<String, Comparable> instance = new
DefaultCacheFactory<String, Comparable>();
+ cache = (CacheSPI<String, Comparable>) instance.createCache(false);
cache.getConfiguration().setClusterName("test");
cache.getConfiguration().setStateRetrievalTimeout(10000);
cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
@@ -616,12 +614,6 @@
assertEquals(0, cache.getNumberOfLocksHeld());
}
- private Map getLockTable(CacheSPI c)
- {
- ComponentRegistry cr = TestingUtil.extractComponentRegistry(c);
- return cr.getComponent("LockTable", Map.class);
- }
-
public void testRemove() throws CacheException, SystemException,
NotSupportedException, HeuristicMixedException, HeuristicRollbackException,
RollbackException
{
cache.put("/a/b/c", null);