[jbosscache-commits] JBoss Cache SVN: r4875 - in core/branches/1.4.X: tests/perf/org/jboss/cache/manualtests and 1 other directory.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Wed Dec 19 07:50:02 EST 2007


Author: manik.surtani at jboss.com
Date: 2007-12-19 07:50:02 -0500 (Wed, 19 Dec 2007)
New Revision: 4875

Added:
   core/branches/1.4.X/tests/perf/org/jboss/cache/manualtests/OptimisticMemLeakTest.java
Modified:
   core/branches/1.4.X/src/org/jboss/cache/interceptors/TxInterceptor.java
Log:
JBCACHE-1246 - memory leak when using fail silently option

Modified: core/branches/1.4.X/src/org/jboss/cache/interceptors/TxInterceptor.java
===================================================================
--- core/branches/1.4.X/src/org/jboss/cache/interceptors/TxInterceptor.java	2007-12-18 20:45:17 UTC (rev 4874)
+++ core/branches/1.4.X/src/org/jboss/cache/interceptors/TxInterceptor.java	2007-12-19 12:50:02 UTC (rev 4875)
@@ -92,7 +92,12 @@
 
         if (optionOverride!= null && optionOverride.isFailSilently() && ctx.getTransaction() != null)
         {
-            suspendedTransaction = txManager.suspend();
+           // make sure we remove the tx and global tx from the transaction table, since we don't care about this transaction
+           // and will just suspend it.  - JBCACHE-1246
+           GlobalTransaction gtx = txTable.remove(ctx.getTransaction());
+           if (gtx != null) txTable.remove(gtx);
+
+           suspendedTransaction = txManager.suspend();
            // set the tx in the invocation context to null now! - JBCACHE-785
            ctx.setTransaction(null);
            ctx.setGlobalTransaction(null);

Added: core/branches/1.4.X/tests/perf/org/jboss/cache/manualtests/OptimisticMemLeakTest.java
===================================================================
--- core/branches/1.4.X/tests/perf/org/jboss/cache/manualtests/OptimisticMemLeakTest.java	                        (rev 0)
+++ core/branches/1.4.X/tests/perf/org/jboss/cache/manualtests/OptimisticMemLeakTest.java	2007-12-19 12:50:02 UTC (rev 4875)
@@ -0,0 +1,50 @@
+package org.jboss.cache.manualtests;
+
+import junit.framework.TestCase;
+import org.jboss.cache.DummyTransactionManagerLookup;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.TreeCache;
+import org.jboss.cache.config.Option;
+
+import javax.transaction.TransactionManager;
+
+/**
+ * To test memory leak reported in http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4112143#4112143
+ *
+ * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
+ */
+public class OptimisticMemLeakTest extends TestCase
+{
+   private TreeCache cache;
+   private TransactionManager tm;
+   private Fqn fqn = Fqn.fromString("/a/b/c");
+   private String key = "key", value = "value";
+
+   protected void tearDown()
+   {
+      cache.stop();
+   }
+
+   protected void setUp() throws Exception
+   {
+      cache = new TreeCache();
+      cache.setNodeLockingScheme("OPTIMISTIC");
+      cache.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+      cache.startService();
+      tm = cache.getTransactionManager();
+   }
+
+   public void testLeakWithFailSilently() throws Exception
+   {
+      tm.begin();
+      Option option = new Option();
+      option.setFailSilently(true);
+      cache.put(fqn, key, value, option);
+      tm.commit();
+
+      int gtxCnt = cache.getTransactionTable().getNumGlobalTransactions();
+      int txCnt = cache.getTransactionTable().getNumLocalTransactions();
+      assertEquals("Global transaction count is > 0", 0, gtxCnt);
+      assertEquals("Local transaction count is > 0", 0, txCnt);
+   }
+}




More information about the jbosscache-commits mailing list