in geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java [622:686]
private void commitResource(TransactionBranch manager) throws RollbackException, HeuristicRollbackException, HeuristicMixedException, SystemException{
XAException cause = null;
try {
try {
manager.getCommitter().commit(manager.getBranchId(), true);
synchronized (this) {
status = Status.STATUS_COMMITTED;
}
return;
} catch (XAException e) {
synchronized (this) {
status = Status.STATUS_ROLLEDBACK;
}
if (e.errorCode == XAException.XA_HEURRB) {
cause = e;
manager.getCommitter().forget(manager.getBranchId());
//throw (HeuristicRollbackException) new HeuristicRollbackException("Error during one-phase commit").initCause(e);
} else if (e.errorCode == XAException.XA_HEURMIX) {
cause = e;
manager.getCommitter().forget(manager.getBranchId());
throw (HeuristicMixedException) new HeuristicMixedException("Error during one-phase commit").initCause(e);
} else if (e.errorCode == XAException.XA_HEURCOM) {
// let's not throw an exception as the transaction has been committed
log.info("Transaction has been heuristically committed");
manager.getCommitter().forget(manager.getBranchId());
} else if (e.errorCode == XAException.XA_RBROLLBACK
|| e.errorCode == XAException.XAER_RMERR
|| e.errorCode == XAException.XAER_NOTA) {
// Per XA spec, XAException.XAER_RMERR from commit means An error occurred in
// committing the work performed on behalf of the transaction branch
// and the branch's work has been rolled back.
// XAException.XAER_NOTA: assume the DB took a unilateral rollback decision and forgot the transaction
log.info("Transaction has been rolled back");
cause = e;
// throw (RollbackException) new RollbackException("Error during one-phase commit").initCause(e);
} else {
cause = e;
//throw (SystemException) new SystemException("Error during one-phase commit").initCause(e);
}
}
} catch (XAException e) {
if (e.errorCode == XAException.XAER_NOTA) {
// NOTA in response to forget, means the resource already forgot the transaction
// ignore
} else {
throw (SystemException) new SystemException("Error during one phase commit").initCause(e);
}
}
if (cause != null) {
if (cause.errorCode == XAException.XA_HEURRB) {
throw (HeuristicRollbackException) new HeuristicRollbackException("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 if (cause.errorCode == XAException.XA_RBROLLBACK
|| cause.errorCode == XAException.XAER_RMERR
|| cause.errorCode == XAException.XAER_NOTA) {
throw (RollbackException) new RollbackException("Error during two phase commit").initCause(cause);
} else {
throw (SystemException) new SystemException("Error during two phase commit").initCause(cause);
}
}
}