[jbosscache-commits] JBoss Cache SVN: r6772 - core/branches/2.2.X/src/main/java/org/jboss/cache/interceptors.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Mon Sep 22 11:53:19 EDT 2008


Author: manik.surtani at jboss.com
Date: 2008-09-22 11:53:19 -0400 (Mon, 22 Sep 2008)
New Revision: 6772

Modified:
   core/branches/2.2.X/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
Log:
JBCACHE-1408:  Optimistic locking + JDBC cache loader + DataSources

Modified: core/branches/2.2.X/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
===================================================================
--- core/branches/2.2.X/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java	2008-09-22 15:40:47 UTC (rev 6771)
+++ core/branches/2.2.X/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java	2008-09-22 15:53:19 UTC (rev 6772)
@@ -30,6 +30,7 @@
 import org.jboss.cache.transaction.TransactionEntry;
 
 import javax.transaction.SystemException;
+import javax.transaction.Transaction;
 import javax.transaction.TransactionManager;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -287,16 +288,27 @@
    {
       if (configuration.isNodeLockingOptimistic())
       {
-         for (Fqn f : affectedFqns)
+         // we need to suspend any txs here since they would be in the tx-committed state and if the loader attempts to
+         // use JTA (E.g., a JDBC CL using connections from a tx aware datasource) it will fail since the tx is in an
+         // illegal state to perform writes.  See JBCACHE-1408.
+         Transaction tx = txMgr.suspend();
+         try
          {
-            // NOT going to store tombstones!!
-            NodeSPI n = dataContainer.peek(f, false, false);
-            if (n != null)
+            for (Fqn f : affectedFqns)
             {
-               Map internalState = n.getInternalState(true);
-               loader.put(f, internalState);
+               // NOT going to store tombstones!!
+               NodeSPI n = dataContainer.peek(f, false, false);
+               if (n != null)
+               {
+                  Map internalState = n.getInternalState(true);
+                  loader.put(f, internalState);
+               }
             }
          }
+         finally
+         {
+            txMgr.resume(tx);
+         }
       }
    }
 




More information about the jbosscache-commits mailing list