Author: dereed
Date: 2012-06-06 16:46:59 -0400 (Wed, 06 Jun 2012)
New Revision: 8502
Modified:
core/support-branches/3.2.2.GA_JBCACHE-1613/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
Log:
[JBPAPP-9264] Backport JBCACHE-1613
Modified:
core/support-branches/3.2.2.GA_JBCACHE-1613/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
===================================================================
---
core/support-branches/3.2.2.GA_JBCACHE-1613/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2012-06-06
20:46:39 UTC (rev 8501)
+++
core/support-branches/3.2.2.GA_JBCACHE-1613/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2012-06-06
20:46:59 UTC (rev 8502)
@@ -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();
}
}
Show replies by thread