@Override public final HeuristicMixedException peerHeuristicMixedException() { final HeuristicMixedException result = new HeuristicMixedException(String.format(getLoggingLocale(), peerHeuristicMixedException$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String peerHeuristicRollbackException = "WFTXN0020: The peer threw a HeuristicRollbackException; see peer logs for more information";
throw hrex; case XAException.XA_HEURMIX: HeuristicMixedException hmex = new HeuristicMixedException(); hmex.initCause(xaex); throw hmex;
@Test public void jtaTransactionManagerWithHeuristicMixedExceptionOnCommit() throws Exception { UserTransaction ut = mock(UserTransaction.class); given(ut.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE, Status.STATUS_ACTIVE); willThrow(new HeuristicMixedException("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_MIXED); } verify(ut).begin(); }
case XAException.XA_HEURMIX: transactionCoordinator.forgetQuietly(transactionXid); HeuristicMixedException hmex = new HeuristicMixedException(); hmex.initCause(xaEx); throw hmex;
throw new HeuristicMixedException(); } else if (unFinishExists) { throw new CommitRequiredException();
private static void rethrowAsJtaHeuristicMixedException(String msg, Throwable cause) throws javax.transaction.HeuristicMixedException { javax.transaction.HeuristicMixedException ret = new javax.transaction.HeuristicMixedException( msg); ret.initCause(cause); throw ret; }
@Override public final HeuristicMixedException peerHeuristicMixedException() { final HeuristicMixedException result = new HeuristicMixedException(String.format(getLoggingLocale(), peerHeuristicMixedException$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String peerHeuristicRollbackException = "WFTXN0020: The peer threw a HeuristicRollbackException; see peer logs for more information";
@Override public final HeuristicMixedException peerHeuristicMixedException() { final HeuristicMixedException result = new HeuristicMixedException(String.format(getLoggingLocale(), peerHeuristicMixedException$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String peerHeuristicRollbackException = "WFTXN0020: The peer threw a HeuristicRollbackException; see peer logs for more information";
public void commit(Xid xid) throws HeuristicMixedException, HeuristicRollbackException, IllegalStateException, SystemException { try { this.terminator.commit(xid, false); } catch (XAException xaex) { switch (xaex.errorCode) { case XAException.XA_HEURCOM: break; case XAException.XA_HEURMIX: throw new HeuristicMixedException(); case XAException.XA_HEURRB: throw new HeuristicRollbackException(); default: logger.error("Unknown state in committing transaction phase.", xaex); throw new SystemException(); } } catch (RuntimeException rex) { logger.error("Unknown state in committing transaction phase.", rex); throw new SystemException(); } }
public void commit(Xid xid) throws HeuristicMixedException, HeuristicRollbackException, IllegalStateException, SystemException { try { this.terminator.commit(xid, false); } catch (XAException xaex) { switch (xaex.errorCode) { case XAException.XA_HEURCOM: break; case XAException.XA_HEURMIX: throw new HeuristicMixedException(); case XAException.XA_HEURRB: throw new HeuristicRollbackException(); default: logger.error("Unknown state in committing transaction phase.", xaex); throw new SystemException(); } } catch (RuntimeException rex) { logger.error("Unknown state in committing transaction phase.", rex); throw new SystemException(); } }
public void rollback(Xid xid) throws HeuristicMixedException, HeuristicCommitException, IllegalStateException, SystemException { try { this.terminator.rollback(xid); } catch (XAException xaex) { switch (xaex.errorCode) { case XAException.XA_HEURRB: break; case XAException.XA_HEURMIX: throw new HeuristicMixedException(); case XAException.XA_HEURCOM: throw new HeuristicCommitException(); default: logger.error("Unknown state in rollingback transaction phase.", xaex); throw new SystemException(); } } catch (RuntimeException rex) { logger.error("Unknown state in rollingback transaction phase.", rex); throw new SystemException(); } }
public void rollback(Xid xid) throws HeuristicMixedException, HeuristicCommitException, IllegalStateException, SystemException { try { this.terminator.rollback(xid); } catch (XAException xaex) { switch (xaex.errorCode) { case XAException.XA_HEURRB: break; case XAException.XA_HEURMIX: throw new HeuristicMixedException(); case XAException.XA_HEURCOM: throw new HeuristicCommitException(); default: logger.error("Unknown state in rollingback transaction phase.", xaex); throw new SystemException(); } } catch (RuntimeException rex) { logger.error("Unknown state in rollingback transaction phase.", rex); throw new SystemException(); } }
public void commit(Xid xid, boolean onePhaseCommit) throws HeuristicMixedException, HeuristicRollbackException, IllegalStateException, SystemException { try { this.terminator.commit(xid, onePhaseCommit); } catch (XAException xaex) { switch (xaex.errorCode) { case XAException.XA_HEURCOM: break; case XAException.XA_HEURMIX: throw new HeuristicMixedException(); case XAException.XA_HEURRB: throw new HeuristicRollbackException(); default: logger.error("Unknown state in committing transaction phase.", xaex); throw new SystemException(); } } catch (RuntimeException rex) { logger.error("Unknown state in committing transaction phase.", rex); throw new SystemException(); } }
public void rollback(Xid xid) throws HeuristicMixedException, HeuristicCommitException, IllegalStateException, SystemException { try { this.terminator.rollback(xid); } catch (XAException xaex) { switch (xaex.errorCode) { case XAException.XA_HEURRB: break; case XAException.XA_HEURMIX: throw new HeuristicMixedException(); case XAException.XA_HEURCOM: throw new HeuristicCommitException(); default: logger.error("Unknown state in rollingback transaction phase.", xaex); throw new SystemException(); } } catch (RuntimeException rex) { logger.error("Unknown state in rollingback transaction phase.", rex); throw new SystemException(); } }
private void rollbackResources(List<TransactionBranch> rms, boolean everRb) throws HeuristicMixedException, SystemException { RollbackTask rollbackTask = new RollbackTask(xid, rms, logMark, txManager); synchronized (this) { status = Status.STATUS_ROLLING_BACK; } rollbackTask.run(); synchronized (this) { status = rollbackTask.getStatus(); } XAException cause = rollbackTask.getCause(); boolean everRolledback = everRb || rollbackTask.isEverRolledBack(); if (cause != null) { if (cause.errorCode == XAException.XA_HEURCOM && everRolledback) { throw (HeuristicMixedException) new HeuristicMixedException("HeuristicMixed error during commit/rolling back").initCause(cause); } else if (cause.errorCode == XAException.XA_HEURMIX) { throw (HeuristicMixedException) new HeuristicMixedException("HeuristicMixed error during commit/rolling back").initCause(cause); } else { throw (SystemException) new SystemException("System Error during commit/rolling back").initCause(cause); } } }
private void commitResources(List<TransactionBranch> rms) throws HeuristicRollbackException, HeuristicMixedException, SystemException { CommitTask commitTask = new CommitTask(xid, rms, logMark, txManager); synchronized (this) { status = Status.STATUS_COMMITTING; } commitTask.run(); synchronized (this) { status = commitTask.getStatus(); } XAException cause = commitTask.getCause(); boolean evercommit = commitTask.isEvercommit(); if (cause != null) { if (cause.errorCode == XAException.XA_HEURRB && !evercommit) { throw (HeuristicRollbackException) new HeuristicRollbackException("Error during two phase commit").initCause(cause); } else if (cause.errorCode == XAException.XA_HEURRB && evercommit) { throw (HeuristicMixedException) new HeuristicMixedException("Error during two phase commit").initCause(cause); } else if (cause.errorCode == XAException.XA_HEURMIX) { throw (HeuristicMixedException) new HeuristicMixedException("Error during two phase commit").initCause(cause); } else { throw (SystemException) new SystemException("Error during two phase commit").initCause(cause); } } }
public void commit(Xid xid) throws HeuristicMixedException, HeuristicRollbackException, IllegalStateException, SystemException { try { this.terminatorTwo.commit(xid, false); } catch (XAException ex) { // error: XA_HEURHAZ, XA_HEURMIX, XA_HEURCOM, XA_HEURRB, XA_RDONLY, XAER_RMERR switch (ex.errorCode) { case XAException.XA_HEURCOM: break; case XAException.XA_HEURRB: throw new HeuristicRollbackException(); case XAException.XA_HEURMIX: throw new HeuristicMixedException(); case XAException.XA_HEURHAZ: throw new SystemException(); case XAException.XA_RDONLY: break; case XAException.XAER_RMERR: throw new SystemException(); default: // should never happen throw new SystemException(); } } catch (RuntimeException ex) { throw new SystemException(); } }
public void commit(Xid xid) throws HeuristicMixedException, HeuristicRollbackException, IllegalStateException, SystemException { try { this.terminatorTwo.commit(xid, false); } catch (XAException ex) { // error: XA_HEURHAZ, XA_HEURMIX, XA_HEURCOM, XA_HEURRB, XA_RDONLY, XAER_RMERR switch (ex.errorCode) { case XAException.XA_HEURCOM: break; case XAException.XA_HEURRB: throw new HeuristicRollbackException(); case XAException.XA_HEURMIX: throw new HeuristicMixedException(); case XAException.XA_HEURHAZ: throw new SystemException(); case XAException.XA_RDONLY: break; case XAException.XAER_RMERR: throw new SystemException(); default: // should never happen throw new SystemException(); } } catch (RuntimeException ex) { throw new SystemException(); } }
private boolean runXaResourceCommitTx() throws HeuristicMixedException { Collection<XAResource> resources = getEnlistedResources(); for (XAResource res : resources) { try { res.commit(xid, false);//todo we only support one phase commit for now, change this!!! } catch (XAException e) { log.warn("exception while committing",e); throw new HeuristicMixedException(e.getMessage()); } } return true; }
private boolean runXaResourceCommitTx() throws HeuristicMixedException { Collection<XAResource> resources = getEnlistedResources(); for (XAResource res : resources) { try { res.commit(xid, false);//todo we only support one phase commit for now, change this!!! } catch (XAException e) { log.warn("exception while committing",e); throw new HeuristicMixedException(e.getMessage()); } } return true; }