log.error("commit called for transaction, but it is not prepared"); throw new XAException(XAException.XAER_PROTO);
if (tx.getState() != TxState.TX_PREPARED) { log.error("commit called for transaction, but it is not prepared"); throw new XAException(XAException.XAER_PROTO); } } else {
   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);            //Invalid xid      if (tx == null)      {         log.error("Cannot find transaction with xid:" + xid);                  throw new XAException(XAException.XAER_NOTA);      }            if (onePhase)      {         TransactionRequest request = new TransactionRequest(TransactionRequest.ONE_PHASE_COMMIT_REQUEST, null, tx);               request.state = tx;             sendTransactionXA(request, connection);      }      else      {         if (tx.getState() != TxState.TX_PREPARED)         {            log.error("commit called for transaction, but it is not prepared");                     throw new XAException(XAException.XAER_PROTO);         }         TransactionRequest request = new TransactionRequest(TransactionRequest.TWO_PHASE_COMMIT_REQUEST, xid, null);         request.xid = xid;               sendTransactionXA(request, connection);      }      tx.setState(TxState.TX_COMMITED);   }