Search in sources :

Example 6 with UnexpectedConditionException

use of com.arjuna.ats.jta.exceptions.UnexpectedConditionException in project narayana by jbosstm.

the class TransactionImple method doRollback.

public void doRollback() throws IllegalStateException, HeuristicMixedException, HeuristicCommitException, HeuristicRollbackException, SystemException {
    try {
        SubordinateAtomicAction subAct = (SubordinateAtomicAction) super._theTransaction;
        if (!endSuspendedRMs()) {
            jtaLogger.i18NLogger.warn_transaction_arjunacore_endsuspendfailed1();
        }
        // JBTM-927 the transaction reaper may have aborted this transaction already
        int res = subAct.status() == ActionStatus.ABORTED ? ActionStatus.ABORTED : subAct.doRollback();
        switch(res) {
            case ActionStatus.ABORTED:
            case ActionStatus.ABORTING:
                TransactionImple.removeTransaction(this);
                break;
            case ActionStatus.H_ROLLBACK:
                throw new HeuristicRollbackException();
            case ActionStatus.H_COMMIT:
                throw new HeuristicCommitException();
            case ActionStatus.H_HAZARD:
            case ActionStatus.H_MIXED:
                throw new HeuristicMixedException();
            default:
                throw new HeuristicMixedException();
        }
    } catch (ClassCastException ex) {
        ex.printStackTrace();
        UnexpectedConditionException unexpectedConditionException = new UnexpectedConditionException(ex.toString());
        unexpectedConditionException.initCause(ex);
        throw unexpectedConditionException;
    }
}
Also used : HeuristicRollbackException(javax.transaction.HeuristicRollbackException) UnexpectedConditionException(com.arjuna.ats.jta.exceptions.UnexpectedConditionException) HeuristicMixedException(javax.transaction.HeuristicMixedException) HeuristicCommitException(javax.transaction.HeuristicCommitException)

Example 7 with UnexpectedConditionException

use of com.arjuna.ats.jta.exceptions.UnexpectedConditionException in project narayana by jbosstm.

the class TransactionImple method doOnePhaseCommit.

public void doOnePhaseCommit() throws IllegalStateException, javax.transaction.HeuristicMixedException, javax.transaction.SystemException, RollbackException {
    try {
        SubordinateAtomicAction subAct = (SubordinateAtomicAction) super._theTransaction;
        if (!endSuspendedRMs())
            _theTransaction.preventCommit();
        int status = subAct.doOnePhaseCommit();
        switch(status) {
            case ActionStatus.COMMITTED:
            case ActionStatus.COMMITTING:
            case ActionStatus.H_COMMIT:
                TransactionImple.removeTransaction(this);
                break;
            case ActionStatus.ABORTED:
            case ActionStatus.ABORTING:
            case ActionStatus.H_ROLLBACK:
                TransactionImple.removeTransaction(this);
                // in which case IllegalState may be a better option?
                throw new RollbackException();
            case ActionStatus.INVALID:
                throw new InvalidTerminationStateException();
            case ActionStatus.H_HAZARD:
            case ActionStatus.H_MIXED:
            default:
                throw new javax.transaction.HeuristicMixedException();
        }
    } catch (ClassCastException ex) {
        ex.printStackTrace();
        UnexpectedConditionException unexpectedConditionException = new UnexpectedConditionException(ex.toString());
        unexpectedConditionException.initCause(ex);
        throw unexpectedConditionException;
    }
}
Also used : InvalidTerminationStateException(com.arjuna.ats.jta.exceptions.InvalidTerminationStateException) UnexpectedConditionException(com.arjuna.ats.jta.exceptions.UnexpectedConditionException) HeuristicMixedException(javax.transaction.HeuristicMixedException) HeuristicRollbackException(javax.transaction.HeuristicRollbackException) RollbackException(javax.transaction.RollbackException)

Aggregations

UnexpectedConditionException (com.arjuna.ats.jta.exceptions.UnexpectedConditionException)7 HeuristicMixedException (javax.transaction.HeuristicMixedException)5 HeuristicRollbackException (javax.transaction.HeuristicRollbackException)5 HeuristicCommitException (javax.transaction.HeuristicCommitException)3 Test (org.junit.Test)2 Uid (com.arjuna.ats.arjuna.common.Uid)1 XATerminatorImple (com.arjuna.ats.internal.jta.transaction.arjunacore.jca.XATerminatorImple)1 InactiveTransactionException (com.arjuna.ats.jta.exceptions.InactiveTransactionException)1 InvalidTerminationStateException (com.arjuna.ats.jta.exceptions.InvalidTerminationStateException)1 NotImplementedException (com.arjuna.ats.jta.exceptions.NotImplementedException)1 RollbackException (com.arjuna.ats.jta.exceptions.RollbackException)1 XidImple (com.arjuna.ats.jta.xa.XidImple)1 RollbackException (javax.transaction.RollbackException)1 XAException (javax.transaction.xa.XAException)1