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

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Jun 2 23:41:38 EDT 2011


Author: tkimura at redhat.com
Date: 2011-06-02 23:41:38 -0400 (Thu, 02 Jun 2011)
New Revision: 37062

Modified:
   labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP07_JBPAPP-6614/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/TransactionImple.java
Log:
JBPAPP-6614 Backport JBTM-575, javax.transaction.RollbackException root cause

Modified: labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP07_JBPAPP-6614/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/TransactionImple.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP07_JBPAPP-6614/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/TransactionImple.java	2011-06-03 02:32:28 UTC (rev 37061)
+++ labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP07_JBPAPP-6614/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/TransactionImple.java	2011-06-03 03:41:38 UTC (rev 37062)
@@ -1428,6 +1428,8 @@
 						return;
 				}
 
+                final Throwable preexistingRollbackOnlyCallerStacktrace = _rollbackOnlyCallerStacktrace;
+
 				switch (_theTransaction.commit(true))
 				{
 					case ActionStatus.COMMITTED:
@@ -1441,14 +1443,25 @@
 					case ActionStatus.ABORTED:
 					case ActionStatus.ABORTING:
                         RollbackException rollbackException = new RollbackException(jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted"));
-                        if(_rollbackOnlyCallerStacktrace != null) {
-                            // we rolled back beacuse the user explicitly told us not to commit. Attach the trace of who did that for debug:
-                            rollbackException.initCause(_rollbackOnlyCallerStacktrace);
+
+                        // Don't mess with the following flow until you've read JBTM-575 in its entirety.
+
+                        if(preexistingRollbackOnlyCallerStacktrace != null) {
+                            // we rolled back because the user (note: NOT a beforeCompletion) explicitly told us not to commit.
+                            // beforeCompletions should not be called in such case anyhow, so getDeferredThrowable is irrelevant.
+                            // Attach the trace of who did that for debug:
+                            rollbackException.initCause(preexistingRollbackOnlyCallerStacktrace);
+                        } else if(_theTransaction.getDeferredThrowable() != null) {
+                            // problems occurring during beforeCompletion (the only place deferredThrowable is set) take priority
+                            // over 'immediately prior' (i.e. after the commit call - likely from within beforeCompletion) calls to setRollbackOnly
+                            // despite the small chance that the causal relationship is not infact valid
+                            rollbackException.initCause(_theTransaction.getDeferredThrowable());
+						} else if(_rollbackOnlyCallerStacktrace != null) {
+                            // we tried to commit but it went wrong, resulting in a call to setRollbackOnly from within a
+                            // beforeCompletion. The beforeCompletion did not then throw an exception as that would be handled above
+							rollbackException.initCause(_rollbackOnlyCallerStacktrace);
                         }
-                        else if(_theTransaction.getDeferredThrowable() != null) {
-                            // we tried to commit but it went wrong - attach the reason for debug:
-							rollbackException.initCause(_theTransaction.getDeferredThrowable());
-						}
+
 						throw rollbackException;
 					default:
 						throw new InvalidTerminationStateException(



More information about the jboss-svn-commits mailing list