[jbosscache-commits] JBoss Cache SVN: r8498 - core/branches/3.2.2.GA_JBCACHE-1613/src/main/java/org/jboss/cache/interceptors.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Wed Jun 6 16:36:34 EDT 2012


Author: dereed
Date: 2012-06-06 16:36:33 -0400 (Wed, 06 Jun 2012)
New Revision: 8498

Modified:
   core/branches/3.2.2.GA_JBCACHE-1613/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
Log:
[JBPAPP-9264] Backport JBCACHE-1613


Modified: core/branches/3.2.2.GA_JBCACHE-1613/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
===================================================================
--- core/branches/3.2.2.GA_JBCACHE-1613/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java	2012-06-06 20:27:01 UTC (rev 8497)
+++ core/branches/3.2.2.GA_JBCACHE-1613/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java	2012-06-06 20:36:33 UTC (rev 8498)
@@ -896,6 +896,13 @@
 
       public void beforeCompletion()
       {
+          beforeCompletion(true);
+      }
+
+      // resetInvocationContext=false should be used by sub classes that call
+      // invocationContextContainer.remove themselves
+      protected void beforeCompletion(boolean resetInvocationContext)
+      {
          if (trace) log.trace("Running beforeCompletion on gtx " + gtx);
 
          if (transactionContext == null)
@@ -916,6 +923,11 @@
          assertCanContinue();
 
          ctx.setOriginLocal(false);
+
+         // JBCACHE-1613: remove the ThreadLocal reference to ctx, in case a different 
+         // thread calls afterCompletion
+         if(resetInvocationContext)
+            invocationContextContainer.remove();
       }
 
       // this should really not be done here -
@@ -935,6 +947,10 @@
             }
          }
 
+         // JBCACHE-1613: Make sure our ThreadLocal is set to ctx, in case beforeCompletion
+         // was called with a different thread
+         invocationContextContainer.set(ctx);
+
          try
          {
             assertCanContinue();
@@ -1068,7 +1084,7 @@
       @Override
       public void beforeCompletion()
       {
-         super.beforeCompletion();
+         super.beforeCompletion(false);
          ctx.setOriginLocal(!remoteLocal); // this is the LOCAL sync handler after all!
          // fetch the modifications before the transaction is committed
          // (and thus removed from the txTable)
@@ -1140,6 +1156,10 @@
             localRollbackOnly = false;
             setTransactionalContext(null, null, null, ctx);
             ctx.setOptionOverrides(originalOptions);
+
+            // JBCACHE-1613: remove the ThreadLocal reference to ctx, in case a different 
+            // thread calls afterCompletion
+            invocationContextContainer.remove();
          }
       }
 



More information about the jbosscache-commits mailing list