@Override public final RollbackException rollbackOnlyRollback() { final RollbackException result = new RollbackException(String.format(getLoggingLocale(), rollbackOnlyRollback$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String invalidTxnState = "WFTXN0018: Invalid transaction state";
public synchronized void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { if (this.transactionStatus == Status.STATUS_ACTIVE) { this.fireCommit(); } else if (this.transactionStatus == Status.STATUS_MARKED_ROLLBACK) { this.fireRollback(); throw new HeuristicRollbackException(); } else if (this.transactionStatus == Status.STATUS_ROLLEDBACK) /* should never happen */ { throw new RollbackException(); } else if (this.transactionStatus == Status.STATUS_COMMITTED) /* should never happen */ { logger.debug("Current transaction has already been committed."); } else { throw new IllegalStateException(); } }
@Override public final RollbackException transactionAlreadyRolledBack(final Transaction tx) { final RollbackException result = new RollbackException(String.format(getLoggingLocale(), transactionAlreadyRolledBack$str(), tx)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String transactionInUnexpectedState = "WFLYEJB0448: Transaction '%s' is in unexpected state (%s)";
@Override public final RollbackException markedRollbackOnly() { final RollbackException result = new RollbackException(String.format(getLoggingLocale(), markedRollbackOnly$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String notActive = "WFTXN0062: Transaction is not active";
@Override public final RollbackException transactionRolledBackByPeer() { final RollbackException result = new RollbackException(String.format(getLoggingLocale(), transactionRolledBackByPeer$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String rollbackOnlyRollback = "WFTXN0017: Rollback-only transaction rolled back";
throw new RollbackException("JTA transaction already completed - probably rolled back"); throw new RollbackException("JTA transaction already rolled back (probably due to a timeout)");
throw new RollbackException("JTA transaction already completed - probably rolled back"); throw new RollbackException("JTA transaction already rolled back (probably due to a timeout)");
if (VERBOSE) writer.fine(exception, e); RollbackException rbEx = new RollbackException(exception); rbEx.initCause(e); throw rbEx;
if (VERBOSE) writer.fine(exception); throw new RollbackException(exception); } else if (status != Status.STATUS_ACTIVE) { String exception =
public boolean enlistResource(XAResource xaRes) throws RollbackException, IllegalStateException, SystemException { if (this.transactionStatus == Status.STATUS_MARKED_ROLLBACK) { throw new RollbackException(); } else if (this.transactionStatus != Status.STATUS_ACTIVE) { throw new IllegalStateException(); descriptor.start(branchXid, XAResource.TMNOFLAGS); } catch (XAException ex) { throw new RollbackException(); // should never happen
@Test public void jtaTransactionManagerWithRollbackExceptionOnCommit() throws Exception { UserTransaction ut = mock(UserTransaction.class); given(ut.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE, Status.STATUS_ACTIVE); willThrow(new RollbackException("unexpected rollback")).given(ut).commit(); try { JtaTransactionManager ptm = newJtaTransactionManager(ut); TransactionTemplate tt = new TransactionTemplate(ptm); tt.execute(new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus status) { // something transactional TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() { @Override public void afterCompletion(int status) { assertTrue("Correct completion status", status == TransactionSynchronization.STATUS_ROLLED_BACK); } }); } }); fail("Should have thrown UnexpectedRollbackException"); } catch (UnexpectedRollbackException ex) { // expected } verify(ut).begin(); }
if (writer.fineEnabled()) writer.fine(exception); throw new RollbackException(exception); } else if (status != Status.STATUS_ACTIVE) { String exception =
if (VERBOSE) writer.fine(exception, e); RollbackException re = new RollbackException(exception); re.initCause(e); throw re; if (VERBOSE) writer.fine(exception, e); throw new RollbackException(exception);
@Test public void newTransactionWithCommitException() { final RollbackException rex = new RollbackException(); MockUOWManager manager = new MockUOWManager() { @Override
private static void rethrowAsJtaRollbackException(String msg, Throwable cause) throws javax.transaction.RollbackException { javax.transaction.RollbackException ret = new javax.transaction.RollbackException( msg); ret.initCause(cause); throw ret; }
private void checkStatusBeforeRegister(String component) throws RollbackException, IllegalStateException { if (status == Status.STATUS_MARKED_ROLLBACK) { throw new RollbackException("Transaction has been marked as rollback only"); } if (isDone()) { throw new IllegalStateException(format("Transaction is done. Cannot register any more %s", component)); } }
private static RollbackException newRollbackException(String message, Throwable cause) { RollbackException exception = new RollbackException(message); exception.initCause(cause); return exception; }
@Override public final RollbackException rollbackOnlyRollback() { final RollbackException result = new RollbackException(String.format(getLoggingLocale(), rollbackOnlyRollback$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String invalidTxnState = "WFTXN0018: Invalid transaction state";
public synchronized void registerSynchronization(Synchronization sync) throws RollbackException, IllegalStateException, SystemException { if (this.transactionStatus == Status.STATUS_MARKED_ROLLBACK) { throw new RollbackException(); } else if (this.transactionStatus == Status.STATUS_ACTIVE) { this.synchronizationList.registerSynchronizationQuietly(sync); logger.debug("{}> register-sync: sync= {}"// , ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()), sync); } else { throw new IllegalStateException(); } }
@Override public final RollbackException transactionRolledBackByPeer() { final RollbackException result = new RollbackException(String.format(getLoggingLocale(), transactionRolledBackByPeer$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String rollbackOnlyRollback = "WFTXN0017: Rollback-only transaction rolled back";