use of com.arjuna.ats.jta.exceptions.UnexpectedConditionException in project narayana by jbosstm.
the class XATerminatorUnitTest method testUnknownTransaction.
@Test
public void testUnknownTransaction() throws Exception {
XATerminatorImple term = new XATerminatorImple();
XidImple xid = new XidImple(new Uid());
try {
term.beforeCompletion(xid);
fail();
} catch (final UnexpectedConditionException ex) {
}
try {
term.prepare(xid);
fail();
} catch (final XAException ex) {
}
try {
term.commit(xid, false);
fail();
} catch (final XAException ex) {
}
try {
term.rollback(xid);
fail();
} catch (final XAException ex) {
}
try {
term.forget(xid);
fail();
} catch (final XAException ex) {
}
}
use of com.arjuna.ats.jta.exceptions.UnexpectedConditionException in project narayana by jbosstm.
the class TransactionImple method doCommit.
public boolean doCommit() throws IllegalStateException, HeuristicMixedException, HeuristicRollbackException, javax.transaction.SystemException {
try {
SubordinateAtomicAction subAct = (SubordinateAtomicAction) super._theTransaction;
int res = subAct.doCommit();
switch(res) {
case ActionStatus.COMMITTED:
case ActionStatus.H_COMMIT:
TransactionImple.removeTransaction(this);
break;
case ActionStatus.COMMITTING:
TransactionImple.removeTransaction(this);
return false;
case ActionStatus.ABORTED:
case ActionStatus.ABORTING:
throw new HeuristicRollbackException();
case ActionStatus.H_ROLLBACK:
throw new HeuristicRollbackException();
case ActionStatus.H_HAZARD:
case ActionStatus.H_MIXED:
throw new HeuristicMixedException();
case ActionStatus.INVALID:
TransactionImple.removeTransaction(this);
throw new IllegalStateException();
default:
// not sure what
throw new HeuristicMixedException();
}
} catch (ClassCastException ex) {
ex.printStackTrace();
UnexpectedConditionException unexpectedConditionException = new UnexpectedConditionException(ex.toString());
unexpectedConditionException.initCause(ex);
throw unexpectedConditionException;
}
return true;
}
use of com.arjuna.ats.jta.exceptions.UnexpectedConditionException in project narayana by jbosstm.
the class ExceptionsUnitTest method test.
@Test
public void test() throws Exception {
InactiveTransactionException ex = new InactiveTransactionException();
ex = new InactiveTransactionException("foobar");
NotImplementedException exp = new NotImplementedException();
exp = new NotImplementedException("foobar");
exp = new NotImplementedException("foobar", new NullPointerException());
exp = new NotImplementedException(new NullPointerException());
RollbackException exp2 = new RollbackException();
exp2 = new RollbackException("foobar");
exp2 = new RollbackException("foobar", new NullPointerException());
exp2 = new RollbackException(new NullPointerException());
UnexpectedConditionException ex2 = new UnexpectedConditionException();
ex2 = new UnexpectedConditionException("foobar");
}
use of com.arjuna.ats.jta.exceptions.UnexpectedConditionException in project narayana by jbosstm.
the class TransactionImple method doCommit.
/**
* Drive the subordinate transaction to commit. It must have previously
* been prepared.
*
*@return true if the transaction was committed
*
* @throws IllegalStateException thrown if the transaction has not been prepared
* or is unknown.
* @throws HeuristicMixedException thrown if a heuristic mixed outcome occurs
* (where some participants committed whilst others rolled back).
* @throws HeuristicRollbackException thrown if the transaction rolled back.
* @throws SystemException thrown if some other error occurs.
*/
public boolean doCommit() throws IllegalStateException, HeuristicMixedException, HeuristicRollbackException, HeuristicCommitException, SystemException {
try {
SubordinateAtomicTransaction subAct = (SubordinateAtomicTransaction) super._theTransaction;
int res = subAct.doCommit();
switch(res) {
case ActionStatus.H_COMMIT:
throw new HeuristicCommitException();
case ActionStatus.COMMITTED:
break;
case ActionStatus.COMMITTING:
return false;
case ActionStatus.ABORTED:
case ActionStatus.ABORTING:
case ActionStatus.H_ROLLBACK:
throw new HeuristicRollbackException();
case ActionStatus.H_HAZARD:
case ActionStatus.H_MIXED:
throw new HeuristicMixedException();
case ActionStatus.INVALID:
throw new IllegalStateException();
default:
// not sure what happened,
throw new HeuristicMixedException();
}
} catch (ClassCastException ex) {
ex.printStackTrace();
UnexpectedConditionException unexpectedConditionException = new UnexpectedConditionException(ex.toString());
unexpectedConditionException.initCause(ex);
throw unexpectedConditionException;
} finally {
TransactionImple.removeTransaction(this);
}
return true;
}
use of com.arjuna.ats.jta.exceptions.UnexpectedConditionException in project narayana by jbosstm.
the class TransactionImple method doRollback.
/**
* Drive the subordinate transaction to roll back. It need not have been previously
* prepared.
*
* @throws IllegalStateException thrown if the transaction is not known by the
* system or has been previously terminated.
* @throws HeuristicMixedException thrown if a heuristic mixed outcome occurs
* (can only happen if the transaction was previously prepared and then only if
* some participants commit whilst others roll back).
* @throws HeuristicCommitException thrown if the transaction commits (can only
* happen if it was previously prepared).
* @throws SystemException thrown if any other error occurs.
*/
public void doRollback() throws IllegalStateException, HeuristicMixedException, HeuristicCommitException, HeuristicRollbackException, SystemException {
try {
SubordinateAtomicTransaction subAct = (SubordinateAtomicTransaction) super._theTransaction;
if (!endSuspendedRMs()) {
jtaxLogger.i18NLogger.warn_jtax_transaction_jts_endsuspendfailed1();
}
int res = subAct.doRollback();
switch(res) {
case ActionStatus.ABORTED:
case ActionStatus.ABORTING:
break;
case ActionStatus.H_ROLLBACK:
throw new HeuristicRollbackException();
case ActionStatus.COMMITTED:
case ActionStatus.COMMITTING:
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;
} finally {
TransactionImple.removeTransaction(this);
}
}
Aggregations