[jboss-svn-commits] JBL Code SVN: r23854 - labs/jbosstm/trunk/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:06:33 EST 2008


Author: jhalliday
Date: 2008-11-13 09:06:33 -0500 (Thu, 13 Nov 2008)
New Revision: 23854

Modified:
   labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/subordinate/TransactionImple.java
Log:
Throw RollbackException rather than heuristic from subordinate tx 1PC where the rollback is clean. JBTM-428


Modified: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/subordinate/TransactionImple.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/subordinate/TransactionImple.java	2008-11-13 14:04:00 UTC (rev 23853)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/subordinate/TransactionImple.java	2008-11-13 14:06:33 UTC (rev 23854)
@@ -1,20 +1,20 @@
 /*
  * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors 
- * as indicated by the @author tags. 
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
  * See the copyright.txt in the distribution for a
- * full listing of individual contributors. 
+ * full listing of individual contributors.
  * This copyrighted material is made available to anyone wishing to use,
  * modify, copy, or redistribute it subject to the terms and conditions
  * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A 
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
  * You should have received a copy of the GNU Lesser General Public License,
  * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  * MA  02110-1301, USA.
- * 
+ *
  * (C) 2005-2006,
  * @author JBoss Inc.
  */
@@ -43,10 +43,7 @@
 
 import java.lang.IllegalStateException;
 
-import javax.transaction.HeuristicCommitException;
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.SystemException;
+import javax.transaction.*;
 
 // https://jira.jboss.org/jira/browse/JBTM-384
 
@@ -68,9 +65,9 @@
 	{
 		this(new SubordinateAtomicAction(timeout));
 	}
-	
+
 	// TODO use the timeout!
-	
+
 	public TransactionImple (AtomicAction act)
 	{
 		super(act);
@@ -131,7 +128,7 @@
 	}
 
 	// Should probably return XA status codes, c.f., XAResource.prepare
-	
+
 	public int doPrepare ()
 	{
 		try
@@ -140,7 +137,7 @@
 
 			if (!endSuspendedRMs())
 				_theTransaction.preventCommit();
-			
+
 			int res = subAct.doPrepare();
 
 			switch (res)
@@ -175,7 +172,7 @@
 			{
 			case ActionStatus.COMMITTED:
 			case ActionStatus.COMMITTING:
-			case ActionStatus.H_COMMIT:				
+			case ActionStatus.H_COMMIT:
 				TransactionImple.removeTransaction(this);
 				break;
 			case ActionStatus.ABORTED:
@@ -188,7 +185,7 @@
 				throw new HeuristicMixedException();
 			case ActionStatus.INVALID:
 				TransactionImple.removeTransaction(this);
-				
+
 				throw new IllegalStateException();
 			default:
 				throw new HeuristicMixedException(); // not sure what
@@ -218,7 +215,7 @@
 					jtaLogger.loggerI18N.warn("com.arjuna.ats.internal.jta.transaction.arjunacore.endsuspendfailed1");
 				}
 			}
-			
+
 			int res = subAct.doRollback();
 
 			switch (res)
@@ -227,7 +224,7 @@
 			case ActionStatus.ABORTING:
 			case ActionStatus.H_ROLLBACK:
 				TransactionImple.removeTransaction(this);
-				
+
 				break;
 			case ActionStatus.H_COMMIT:
 				throw new HeuristicCommitException();
@@ -263,9 +260,9 @@
 			TransactionImple.removeTransaction(this);
 		}
 	}
-	
+
 	public void doOnePhaseCommit () throws IllegalStateException,
-			javax.transaction.HeuristicRollbackException, javax.transaction.SystemException
+			javax.transaction.HeuristicRollbackException, javax.transaction.SystemException, RollbackException
 	{
 		try
 		{
@@ -273,17 +270,20 @@
 
 			if (!endSuspendedRMs())
 				_theTransaction.preventCommit();
-			
-			int status = subAct.doOnePhaseCommit();		
 
+			int status = subAct.doOnePhaseCommit();
+
 			switch (status)
 			{
 			case ActionStatus.COMMITTED:
 			case ActionStatus.H_COMMIT:
 				TransactionImple.removeTransaction(this);
-				
 				break;
 			case ActionStatus.ABORTED:
+                TransactionImple.removeTransaction(this);
+                // JBTM-428. Note also this may be because the tx was set rollback only,
+                // in which case IllegalState may be a better option?
+                throw new RollbackException();
 			case ActionStatus.ABORTING:
 			case ActionStatus.H_HAZARD:
 			case ActionStatus.H_MIXED:
@@ -311,7 +311,7 @@
 					+ super._theTransaction + " >";
 		}
 	}
-	
+
 	protected void commitAndDisassociate ()
 			throws javax.transaction.RollbackException,
 			javax.transaction.HeuristicMixedException,
@@ -342,11 +342,11 @@
 	/**
 	 * Because of recovery, it is possible that a transaction may not be able to
 	 * activate itself from the log initially, forcing us to retry later.
-	 * 
+	 *
 	 * @return <code>true</code> if the transaction was activated, <code>false</code>
 	 * otherwise.
 	 */
-	
+
     public boolean activated ()
     {
     	return true;




More information about the jboss-svn-commits mailing list