if (log.isTraceEnabled()) { log.trace("Commiting xid=" + xid + ", onePhase=" + onePhase); }
if (trace) { log.trace("Commiting xid=" + xid + ", onePhase=" + onePhase); }
   public void commit(Xid xid, boolean onePhase, ConnectionDelegate connection) throws XAException   {      if (log.isTraceEnabled()) { log.trace("Commiting xid=" + xid + ", onePhase=" + onePhase); }            TxState tx = removeTx(xid);                if (onePhase)      {         //Invalid xid         if (tx == null)         {            log.error("Cannot find transaction with xid:" + xid);                     throw new XAException(XAException.XAER_NOTA);         }                  TransactionRequest request =            new TransactionRequest(TransactionRequest.ONE_PHASE_COMMIT_REQUEST, null, tx);         request.state = tx;             sendTransactionXA(request, connection);      }      else      {         if (tx != null)         {            if (tx.getState() != TxState.TX_PREPARED)            {               log.error("commit called for transaction, but it is not prepared");                        throw new XAException(XAException.XAER_PROTO);            }         }         else         {            //It's possible we don't actually have the prepared tx here locally - this            //may happen if we have recovered from failure and the transaction manager            //is calling commit on the transaction as part of the recovery process.         }         TransactionRequest request =            new TransactionRequest(TransactionRequest.TWO_PHASE_COMMIT_REQUEST, xid, null);         request.xid = xid;               sendTransactionXA(request, connection);      }      if (tx != null)      {         tx.setState(TxState.TX_COMMITED);      }   }