Author: manik.surtani(a)jboss.com
Date: 2008-05-27 15:42:22 -0400 (Tue, 27 May 2008)
New Revision: 5891
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java
core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java
Log:
Fixed context scrubbing
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java 2008-05-27
19:31:25 UTC (rev 5890)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java 2008-05-27
19:42:22 UTC (rev 5891)
@@ -54,7 +54,15 @@
ctx.setGlobalTransaction(gtx);
if (entry == null)
{
- if (gtx != null) ctx.setTransactionEntry(txTable.get(gtx));
+ if (gtx != null)
+ {
+ ctx.setTransactionEntry(txTable.get(gtx));
+ }
+ else if (tx == null)
+ {
+ // then nullify the transaction entry as well
+ ctx.setTransactionEntry(null);
+ }
}
else
{
Modified: core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java 2008-05-27
19:31:25 UTC (rev 5890)
+++ core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java 2008-05-27
19:42:22 UTC (rev 5891)
@@ -4,13 +4,12 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.util.internals.EvictionController;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.eviction.LRUConfiguration;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
-import org.jboss.cache.misc.TestingUtil;
+import org.jboss.cache.util.internals.EvictionController;
import static org.testng.Assert.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -210,10 +209,13 @@
}
}
- public void testResidencyAndPesimistickLocking() throws Exception
+ public void testResidencyAndPessimisticLocking() throws Exception
{
cache.put(Fqn.fromString("/a/b"), "key", "value");
TransactionManager txManager = cache.getTransactionManager();
+
+ assert cache.getNumberOfLocksHeld() == 0 : "Should have no stale
locks!";
+
txManager.begin();
cache.getRoot().getChild(Fqn.fromString("/a/b")).setResident(true);
cache.getRoot().getChild(Fqn.fromString("/a/b")).put("k2",
"v2");
@@ -221,6 +223,8 @@
txManager.rollback();
assertTrue(cache.getRoot().getChild(Fqn.fromString("/a/b")).isResident());
+ assert cache.getNumberOfLocksHeld() == 0 : "Should have no stale
locks!";
+
txManager.begin();
cache.getRoot().getChild(Fqn.fromString("/a/b")).setResident(false);
cache.getRoot().getChild(Fqn.fromString("/a/b")).put("k2",
"v2");
Show replies by thread