if (tranState == null) {
XAResourceManager rm = ra.getXAResourceManager();
ContextManager inDoubtCM = rm.find(xid);
// RM also does not know about this xid.
if (inDoubtCM == null)
throw new XAException(XAException.XAER_NOTA);
ContextService csf = ContextService.getFactory();
csf.setCurrentContextManager(inDoubtCM);
try {
rm.commit(inDoubtCM, xid_im, onePhase);
// close the connection/transaction since it can never
// be used again.
inDoubtCM.cleanupOnError(StandardException.closeException());
return;
} catch (StandardException se) {
// The rm threw an exception, clean it up in the approprate
// context. There is no transactionResource to handle the
// exception for us.
inDoubtCM.cleanupOnError(se);
throw wrapInXAException(se);
} finally {
csf.resetCurrentContextManager(inDoubtCM);
}
}
synchronized (tranState) {
checkUserCredentials(tranState.creatingResource);
// Check the transaction is no associated with
// any XAResource.
switch (tranState.associationState) {
case XATransactionState.T0_NOT_ASSOCIATED:
break;
case XATransactionState.TRO_FAIL:
throw new XAException(tranState.rollbackOnlyCode);
default:
throw new XAException(XAException.XAER_PROTO);
}
if (tranState.suspendedList != null && tranState.suspendedList.size() != 0)
throw new XAException(XAException.XAER_PROTO);
if (tranState.isPrepared == onePhase)
throw new XAException(XAException.XAER_PROTO);
try {
tranState.xa_commit(onePhase);
} catch (SQLException sqle) {
throw wrapInXAException(sqle);