[jboss-svn-commits] JBL Code SVN: r30147 - in labs/jbosstm/trunk: ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sat Nov 14 16:15:50 EST 2009
Author: mark.little at jboss.com
Date: 2009-11-14 16:15:49 -0500 (Sat, 14 Nov 2009)
New Revision: 30147
Modified:
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/BasicAction.java
labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/TransactionImple.java
labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/exceptions/InactiveTransactionException.java
labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/exceptions/InvalidTerminationStateException.java
labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/exceptions/UnexpectedConditionException.java
labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/transaction/jts/TransactionImple.java
Log:
https://jira.jboss.org/jira/browse/JBTM-234
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/BasicAction.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/BasicAction.java 2009-11-13 21:54:34 UTC (rev 30146)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/BasicAction.java 2009-11-14 21:15:49 UTC (rev 30147)
@@ -497,10 +497,20 @@
// if (lockMutex())
{
+ /*
+ * If we are active then change status. Otherwise it may be an error so check status.
+ */
+
if (actionStatus == ActionStatus.RUNNING)
actionStatus = ActionStatus.ABORT_ONLY;
- res = (actionStatus == ActionStatus.ABORT_ONLY);
+ /*
+ * Since the reason to call this method is to make sure the transaction
+ * only aborts, check the status now and if it has aborted or will abort then
+ * we'll consider it a success.
+ */
+
+ res = ((actionStatus == ActionStatus.ABORT_ONLY) || (actionStatus == ActionStatus.ABORTED) || (actionStatus == ActionStatus.ABORTING));
// unlockMutex();
}
Modified: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/TransactionImple.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/TransactionImple.java 2009-11-13 21:54:34 UTC (rev 30146)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/TransactionImple.java 2009-11-14 21:15:49 UTC (rev 30147)
@@ -58,6 +58,8 @@
import java.util.*;
import javax.transaction.RollbackException;
+import javax.transaction.Status;
+
import java.lang.IllegalStateException;
import java.util.concurrent.ConcurrentHashMap;
@@ -83,6 +85,9 @@
* @message com.arjuna.ats.internal.jta.transaction.arjunacore.lastResourceOptimisationInterface
* [com.arjuna.ats.internal.jta.transaction.arjunacore.lastResourceOptimisationInterface] -
* failed to load Last Resource Optimisation Interface
+ * @message com.arjuna.ats.internal.jta.transaction.arjunacore.invalidstate
+ * [com.arjuna.ats.internal.jta.transaction.arjunacore.invalidstate] The
+ * transaction is in an invalid state!
*/
public class TransactionImple implements javax.transaction.Transaction,
@@ -177,9 +182,6 @@
* other resources, this is then the same as having simply been forced to
* rollback the transaction during phase 1.
*
- * @message com.arjuna.ats.internal.jta.transaction.arjunacore.invalidstate
- * [com.arjuna.ats.internal.jta.transaction.arjunacore.invalidstate]
- * Invalid transaction state
* @message com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted
* [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted]
* Could not commit transaction.
@@ -344,42 +346,51 @@
public void setRollbackOnly() throws java.lang.IllegalStateException,
javax.transaction.SystemException
{
- if (jtaLogger.logger.isDebugEnabled())
- {
- jtaLogger.logger.debug(DebugLevel.FUNCTIONS,
- VisibilityLevel.VIS_PUBLIC,
- com.arjuna.ats.jta.logging.FacilityCode.FAC_JTA,
- "TransactionImple.setRollbackOnly");
- }
+ if (jtaLogger.logger.isDebugEnabled())
+ {
+ jtaLogger.logger.debug(DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC,
+ com.arjuna.ats.jta.logging.FacilityCode.FAC_JTA,
+ "TransactionImple.setRollbackOnly");
+ }
- if (_theTransaction != null)
- {
- if (!_theTransaction.preventCommit())
- {
- switch (_theTransaction.status())
- {
- case ActionStatus.ABORTED:
- case ActionStatus.ABORTING:
- break;
- default:
- throw new IllegalStateException(
- jtaLogger.logMesg
- .getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive"));
- }
- }
- else
- {
- // keep a record of why we are rolling back i.e. who called us first, it's a useful debug aid.
- if(_rollbackOnlyCallerStacktrace == null)
- {
- _rollbackOnlyCallerStacktrace = new Throwable("setRollbackOnly called from:");
- }
- }
- }
- else
- throw new IllegalStateException(
- jtaLogger.logMesg
- .getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive"));
+ if (_theTransaction != null)
+ {
+ /*
+ * Try to mark the transaction as rollback-only. If that fails figure out why.
+ */
+
+ if (!_theTransaction.preventCommit())
+ {
+ switch (getStatus())
+ {
+ case Status.STATUS_ROLLEDBACK:
+ case Status.STATUS_ROLLING_BACK:
+ break;
+ case Status.STATUS_PREPARING:
+ case Status.STATUS_PREPARED:
+ throw new InvalidTerminationStateException(
+ jtaLogger.logMesg
+ .getString("com.arjuna.ats.internal.jta.transaction.arjunacore.invalidstate"));
+ default:
+ throw new InactiveTransactionException(
+ jtaLogger.logMesg
+ .getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive"));
+ }
+ }
+ else
+ {
+ // keep a record of why we are rolling back i.e. who called us first, it's a useful debug aid.
+ if(_rollbackOnlyCallerStacktrace == null)
+ {
+ _rollbackOnlyCallerStacktrace = new Throwable("setRollbackOnly called from:");
+ }
+ }
+ }
+ else
+ throw new IllegalStateException(
+ jtaLogger.logMesg
+ .getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive"));
}
public int getStatus() throws javax.transaction.SystemException
Modified: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/exceptions/InactiveTransactionException.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/exceptions/InactiveTransactionException.java 2009-11-13 21:54:34 UTC (rev 30146)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/exceptions/InactiveTransactionException.java 2009-11-14 21:15:49 UTC (rev 30147)
@@ -34,7 +34,11 @@
import javax.transaction.SystemException;
/**
- * Exception may be thrown under certain circumstances.
+ * Exception may be thrown under certain circumstances. Typically
+ * this is when we would like to throw IllegalStateException to indicate
+ * that the transaction is in an illegal state for the action attempted
+ * (inactive), but JTA has reserved that for something else, e.g., that
+ * there is no transaction associated with the calling thread.
*
* @author Mark Little (mark at arjuna.com)
* @version $Id: NotImplementedException.java 2342 2006-03-30 13:06:17Z $
Modified: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/exceptions/InvalidTerminationStateException.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/exceptions/InvalidTerminationStateException.java 2009-11-13 21:54:34 UTC (rev 30146)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/exceptions/InvalidTerminationStateException.java 2009-11-14 21:15:49 UTC (rev 30147)
@@ -34,7 +34,11 @@
import javax.transaction.SystemException;
/**
- * Exception may be thrown under certain circumstances.
+ * Exception may be thrown under certain circumstances. Typically
+ * this is when an action has been attempted, the state of
+ * the transaction is invalid for that action and JTA has reserved
+ * IllegalStateException to mean something else entirely that we
+ * can't use!
*
* @author Mark Little (mark at arjuna.com)
* @version $Id: NotImplementedException.java 2342 2006-03-30 13:06:17Z $
Modified: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/exceptions/UnexpectedConditionException.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/exceptions/UnexpectedConditionException.java 2009-11-13 21:54:34 UTC (rev 30146)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/exceptions/UnexpectedConditionException.java 2009-11-14 21:15:49 UTC (rev 30147)
@@ -34,7 +34,10 @@
import javax.transaction.SystemException;
/**
- * Exception may be thrown under certain circumstances.
+ * Exception may be thrown under certain circumstances when we are
+ * forced to throw a SystemException but want to give more information.
+ * Blame JTA because it tends to fail the user in a way that JTS
+ * didn't do!
*
* @author Mark Little (mark at arjuna.com)
* @version $Id: NotImplementedException.java 2342 2006-03-30 13:06:17Z $
Modified: labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/transaction/jts/TransactionImple.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/transaction/jts/TransactionImple.java 2009-11-13 21:54:34 UTC (rev 30146)
+++ labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/transaction/jts/TransactionImple.java 2009-11-14 21:15:49 UTC (rev 30147)
@@ -45,6 +45,7 @@
import org.omg.CosTransactions.*;
+import com.arjuna.ats.arjuna.coordinator.ActionStatus;
import com.arjuna.ats.arjuna.coordinator.BasicAction;
import com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator;
import com.arjuna.ats.arjuna.coordinator.TransactionReaper;
@@ -72,6 +73,8 @@
import javax.transaction.RollbackException;
import javax.transaction.HeuristicMixedException;
+import javax.transaction.Status;
+
import java.lang.SecurityException;
import java.lang.IllegalStateException;
import org.omg.CosTransactions.SubtransactionsUnavailable;
@@ -114,6 +117,8 @@
* @message com.arjuna.ats.internal.jta.transaction.jts.lastResourceOptimisationInterface
* [com.arjuna.ats.internal.jta.transaction.jts.lastResourceOptimisationInterface] - failed
* to load Last Resource Optimisation Interface
+ * @message com.arjuna.ats.internal.jta.transaction.jts.setrollback
+ * [com.arjuna.ats.internal.jta.transaction.jts.setrollback] - setRollbackOnly called from:
*/
public class TransactionImple implements javax.transaction.Transaction,
@@ -397,37 +402,55 @@
public void setRollbackOnly () throws java.lang.IllegalStateException,
javax.transaction.SystemException
{
- if (jtaLogger.logger.isDebugEnabled())
- {
- jtaLogger.logger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, com.arjuna.ats.jta.logging.FacilityCode.FAC_JTA, "TransactionImple.setRollbackOnly");
- }
+ if (jtaLogger.logger.isDebugEnabled())
+ {
+ jtaLogger.logger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, com.arjuna.ats.jta.logging.FacilityCode.FAC_JTA, "TransactionImple.setRollbackOnly");
+ }
- if (_theTransaction != null)
- {
- try
- {
- _theTransaction.rollbackOnly();
- // keep a record of why we are rolling back i.e. who called us first, it's a useful debug aid.
- if(_rollbackOnlyCallerStacktrace == null)
- {
- _rollbackOnlyCallerStacktrace = new Throwable("setRollbackOnly called from:");
- }
- }
- catch (org.omg.CosTransactions.NoTransaction e3)
- {
- throw new IllegalStateException(
- jtaLogger.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.notx"), e3);
- }
- catch (org.omg.CORBA.SystemException e4)
- {
- javax.transaction.SystemException systemException = new javax.transaction.SystemException(e4.toString());
- systemException.initCause(e4);
- throw systemException;
- }
- }
- else
- throw new IllegalStateException(
- jtaLogger.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.inactivetx"));
+ if (_theTransaction != null)
+ {
+ try
+ {
+ _theTransaction.rollbackOnly();
+ // keep a record of why we are rolling back i.e. who called us first, it's a useful debug aid.
+ if (_rollbackOnlyCallerStacktrace == null)
+ {
+ _rollbackOnlyCallerStacktrace = new Throwable(jtaLogger.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.notx"));
+ }
+ }
+ catch (org.omg.CosTransactions.NoTransaction e3)
+ {
+ throw new IllegalStateException(
+ jtaLogger.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.notx"), e3);
+ }
+ catch (final INVALID_TRANSACTION ex)
+ {
+ switch (getStatus())
+ {
+ case Status.STATUS_ROLLEDBACK:
+ case Status.STATUS_ROLLING_BACK:
+ break;
+ case Status.STATUS_PREPARING:
+ case Status.STATUS_PREPARED:
+ throw new InvalidTerminationStateException(
+ jtaLogger.logMesg
+ .getString("com.arjuna.ats.internal.jta.transaction.arjunacore.invalidstate"));
+ default:
+ throw new InactiveTransactionException(
+ jtaLogger.logMesg
+ .getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive"));
+ }
+ }
+ catch (org.omg.CORBA.SystemException e4)
+ {
+ javax.transaction.SystemException systemException = new javax.transaction.SystemException(e4.toString());
+ systemException.initCause(e4);
+ throw systemException;
+ }
+ }
+ else
+ throw new IllegalStateException(
+ jtaLogger.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.inactivetx"));
}
public int getStatus () throws javax.transaction.SystemException
More information about the jboss-svn-commits
mailing list