[jboss-svn-commits] JBL Code SVN: r23859 - labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/subordinate.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Nov 13 09:45:10 EST 2008


Author: jhalliday
Date: 2008-11-13 09:45:10 -0500 (Thu, 13 Nov 2008)
New Revision: 23859

Modified:
   labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/subordinate/SubordinateAtomicAction.java
Log:
Merged JBTM-429 fix from trunk to 4.2.3.SP


Modified: labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/subordinate/SubordinateAtomicAction.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/subordinate/SubordinateAtomicAction.java	2008-11-13 14:43:23 UTC (rev 23858)
+++ labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/subordinate/SubordinateAtomicAction.java	2008-11-13 14:45:10 UTC (rev 23859)
@@ -124,7 +124,15 @@
 
 	public int doPrepare ()
 	{
-		if (super.beforeCompletion()) {
+        int status = super.status();
+
+        // In JTA spec, beforeCompletions are run on commit attempts only, not rollbacks.
+        // We attempt to mimic that here, even though we are outside the scope of the spec.
+        // note it's not perfect- async timeout/rollback means there is a race condition in which we
+        // can still call beforeCompletion on rollbacks, but that's not too bad as skipping it is really
+        // just an optimization anyhow.  JBTM-429
+        if ( !(status == ActionStatus.ABORT_ONLY || status == ActionStatus.ABORTING) && super.beforeCompletion())
+        {
             int outcome = super.prepare(true);
             if(outcome == TwoPhaseOutcome.PREPARE_READONLY) {
                 // we won't get called again, so we need to clean up
@@ -207,21 +215,28 @@
 	}
 
 	public int doOnePhaseCommit ()
-	{
-	    int status;
+    {
+        int status = super.status();
 
-	    if (beforeCompletion())
-	    {
-		status = super.End(true);
-	    }
-	    else
-	        status = ActionStatus.ABORTED;
+        // In JTA spec, beforeCompletions are run on commit attempts only, not rollbacks.
+        // We attempt to mimic that here, even though we are outside the scope of the spec.
+        // note it's not perfect- async timeout/rollback means there is a race condition in which we
+        // can still call beforeCompletion on rollbacks, but that's not too bad as skipping it is really
+        // just an optimization anyhow. JBTM-429
+        // behaviour relies on java's lazy evaluation of the if clause:
+        if (status == ActionStatus.ABORT_ONLY || super.beforeCompletion())
+        {
+            status = super.End(true);
+        }
+        else
+        {
+            status = ActionStatus.ABORTED;
+        }
 
-            afterCompletion(status);
+        afterCompletion(status);
+        return status;
+    }
 
-            return status;
-	}
-
 	public void doForget ()
 	{
 		super.forgetHeuristics();




More information about the jboss-svn-commits mailing list