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 HeuristicRollbackException peerHeuristicRollbackException() { final HeuristicRollbackException result = new HeuristicRollbackException(String.format(getLoggingLocale(), peerHeuristicRollbackException$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String failedToAcquireConnection = "WFTXN0021: Failed to acquire a connection for this operation";
} else if (transactionContext.isRollbackOnly()) { this.compensableRollback(); throw new HeuristicRollbackException();
throw stateEx; case XAException.XA_HEURRB: HeuristicRollbackException hrex = new HeuristicRollbackException(); hrex.initCause(xaex); throw hrex;
this.fireCompensableRollback(compensable); failure = false; throw new HeuristicRollbackException(); } else { failure = false;
protected void invokeTransactionCommitIfNotLocalTransaction(CompensableTransaction compensable) throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { Transaction transaction = compensable.getTransaction(); org.bytesoft.transaction.TransactionContext transactionContext = transaction.getTransactionContext(); TransactionParticipant transactionCoordinator = this.beanFactory.getTransactionNativeParticipant(); TransactionXid transactionXid = transactionContext.getXid(); try { transactionCoordinator.end(transactionContext, XAResource.TMSUCCESS); TransactionContext compensableContext = compensable.getTransactionContext(); logger.error("{}> jta-transaction in try-phase cannot be xa transaction.", ByteUtils.byteArrayToString(compensableContext.getXid().getGlobalTransactionId())); transactionCoordinator.rollback(transactionXid); throw new HeuristicRollbackException(); } catch (XAException xaEx) { transactionCoordinator.forgetQuietly(transactionXid); SystemException sysEx = new SystemException(xaEx.errorCode); sysEx.initCause(xaEx); throw sysEx; } }
protected void invokeCompensableCommitIfNotLocalTransaction(CompensableTransaction compensable) throws HeuristicRollbackException, SystemException { TransactionParticipant transactionCoordinator = this.beanFactory.getTransactionNativeParticipant(); Transaction transaction = compensable.getTransaction(); org.bytesoft.transaction.TransactionContext transactionContext = transaction.getTransactionContext(); TransactionXid transactionXid = transactionContext.getXid(); try { transactionCoordinator.end(transactionContext, XAResource.TMSUCCESS); TransactionContext compensableContext = compensable.getTransactionContext(); logger.error("{}| jta-transaction in compensating-phase cannot be xa transaction.", ByteUtils.byteArrayToString(compensableContext.getXid().getGlobalTransactionId())); transactionCoordinator.rollback(transactionXid); throw new HeuristicRollbackException(); } catch (XAException xaex) { transactionCoordinator.forgetQuietly(transactionXid); SystemException sysEx = new SystemException(xaex.errorCode); sysEx.initCause(xaex); throw sysEx; } }
@Test public void jtaTransactionManagerWithHeuristicRollbackExceptionOnCommit() throws Exception { UserTransaction ut = mock(UserTransaction.class); given(ut.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE, Status.STATUS_ACTIVE); willThrow(new HeuristicRollbackException("heuristic exception")).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_UNKNOWN); } }); } }); fail("Should have thrown HeuristicCompletionException"); } catch (HeuristicCompletionException ex) { // expected assertTrue(ex.getOutcomeState() == HeuristicCompletionException.STATE_ROLLED_BACK); } verify(ut).begin(); }
protected void invokeCompensableCommitIfLocalTransaction(CompensableTransaction compensable) throws HeuristicRollbackException, SystemException { TransactionParticipant transactionCoordinator = this.beanFactory.getTransactionNativeParticipant(); Transaction transaction = compensable.getTransaction(); org.bytesoft.transaction.TransactionContext transactionContext = transaction.getTransactionContext(); TransactionXid transactionXid = transactionContext.getXid(); try { transactionCoordinator.end(transactionContext, XAResource.TMSUCCESS); transactionCoordinator.commit(transactionXid, true); } catch (XAException xaex) { switch (xaex.errorCode) { case XAException.XA_HEURCOM: transactionCoordinator.forgetQuietly(transactionXid); break; case XAException.XA_HEURRB: transactionCoordinator.forgetQuietly(transactionXid); HeuristicRollbackException hrex = new HeuristicRollbackException(); hrex.initCause(xaex); throw hrex; default: transactionCoordinator.forgetQuietly(transactionXid); // TODO SystemException sysEx = new SystemException(xaex.errorCode); sysEx.initCause(xaex); throw sysEx; } } }
case XAException.XA_HEURRB: transactionCoordinator.forgetQuietly(transactionXid); HeuristicRollbackException hrex = new HeuristicRollbackException(); hrex.initCause(xaEx); throw hrex;
throw new SystemException(XAException.XAER_RMERR); } else if (rolledbackExists) { throw new HeuristicRollbackException();
private static void rethrowAsJtaHeuristicRollbackException(String msg, Throwable cause) throws javax.transaction.HeuristicRollbackException { javax.transaction.HeuristicRollbackException ret = new javax.transaction.HeuristicRollbackException( msg); ret.initCause(cause); throw ret; }
private void checkForTransactionExtraIfNecessary() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, CommitRequiredException, SystemException { if (this.transactionalExtra != null) /* for ByteTCC */ { if (this.participantList.isEmpty() == false && this.participant == null) /* see initGetTransactionStrategy */ { this.participantRollback(); throw new HeuristicRollbackException(); } else if (this.participantList.size() > 1) { this.participantRollback(); throw new HeuristicRollbackException(); } } // end-if (this.transactionalExtra != null) }
private void checkForTransactionExtraIfNecessary() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, CommitRequiredException, SystemException { if (this.transactionalExtra != null) /* for ByteTCC */ { if (this.participantList.isEmpty() == false && this.participant == null) /* see initGetTransactionStrategy */ { this.participantRollback(); throw new HeuristicRollbackException(); } else if (this.participantList.size() > 1) { this.participantRollback(); throw new HeuristicRollbackException(); } } // end-if (this.transactionalExtra != null) }
private void checkForTransactionExtraIfNecessary() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, CommitRequiredException, SystemException { if (this.transactionalExtra != null) /* for ByteTCC */ { if (this.participantList.isEmpty() == false && this.participant == null) /* see initGetTransactionStrategy */ { this.participantRollback(); throw new HeuristicRollbackException(); } else if (this.participantList.size() > 1) { this.participantRollback(); throw new HeuristicRollbackException(); } } // end-if (this.transactionalExtra != null) }
public synchronized void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, CommitRequiredException, 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(); } }
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(); } }
public synchronized void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, CommitRequiredException, 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 HeuristicRollbackException peerHeuristicRollbackException() { final HeuristicRollbackException result = new HeuristicRollbackException(String.format(getLoggingLocale(), peerHeuristicRollbackException$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String failedToAcquireConnection = "WFTXN0021: Failed to acquire a connection for this operation";
@Override public final HeuristicRollbackException peerHeuristicRollbackException() { final HeuristicRollbackException result = new HeuristicRollbackException(String.format(getLoggingLocale(), peerHeuristicRollbackException$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String failedToAcquireConnection = "WFTXN0021: Failed to acquire a connection for this operation";