// can still set the status to STATUS_MARKED_ROLLBACK.
try {
fireBeforeCompletionEvent();
} catch (BitronixSystemException ex) {
rollback();
throw new BitronixRollbackException("SystemException thrown during beforeCompletion cycle caused transaction rollback", ex);
} catch (RuntimeException ex) {
rollback();
throw new BitronixRollbackException("RuntimeException thrown during beforeCompletion cycle caused transaction rollback", ex);
}
// The following if statements and try/catch block must not be included in the prepare try-catch block as
// they call rollback().
// Doing so would call fireAfterCompletionEvent() twice in case one of those conditions are true.
if (timedOut()) {
if (log.isDebugEnabled()) { log.debug("transaction timed out"); }
rollback();
throw new BitronixRollbackException("transaction timed out and has been rolled back");
}
try {
delistUnclosedResources(XAResource.TMSUCCESS);
} catch (BitronixRollbackException ex) {
if (log.isDebugEnabled()) { log.debug("delistment error causing transaction rollback", ex); }
rollback();
// the caught BitronixRollbackException's message is pre-formatted to be appended to this message
throw new BitronixRollbackException("delistment error caused transaction rollback" + ex.getMessage());
}
if (status == Status.STATUS_MARKED_ROLLBACK) {
if (log.isDebugEnabled()) { log.debug("transaction marked as rollback only"); }
rollback();
throw new BitronixRollbackException("transaction was marked as rollback only and has been rolled back");
}
try {
List<XAResourceHolderState> interestedResources;
// prepare phase
try {
if (log.isDebugEnabled()) { log.debug("committing, " + resourceManager.size() + " enlisted resource(s)"); }
interestedResources = preparer.prepare(this);
}
catch (RollbackException ex) {
if (log.isDebugEnabled()) { log.debug("caught rollback exception during prepare, trying to rollback"); }
// rollbackPrepareFailure might throw a SystemException that will 'swallow' the RollbackException which is
// what we want in that case as the transaction has not been rolled back and some resources are now left in-doubt.
rollbackPrepareFailure(ex);
throw new BitronixRollbackException("transaction failed to prepare: " + this, ex);
}
// commit phase
if (log.isDebugEnabled()) { log.debug(interestedResources.size() + " interested resource(s)"); }