(ackMode != Session.CLIENT_ACKNOWLEDGE && state.getCurrentTxId() == null))
(state.isXA() && state.getCurrentTxId() == null))
   public Object handlePostDeliver(Invocation invocation) throws Throwable   {       MethodInvocation mi = (MethodInvocation)invocation;      SessionState state = getState(invocation);            int ackMode = state.getAcknowledgeMode();            boolean cancel = ((Boolean)mi.getArguments()[0]).booleanValue();            if (cancel && ackMode != Session.AUTO_ACKNOWLEDGE && ackMode != Session.DUPS_OK_ACKNOWLEDGE)      {         throw new IllegalStateException("Ack mode must be AUTO_ACKNOWLEDGE or DUPS_OK_ACKNOWLEDGE");      }            if (ackMode == Session.AUTO_ACKNOWLEDGE ||          ackMode == Session.DUPS_OK_ACKNOWLEDGE ||          (ackMode != Session.CLIENT_ACKNOWLEDGE && state.getCurrentTxId() == null))      {         // We acknowledge immediately on a non-transacted session that does not want to         // CLIENT_ACKNOWLEDGE, or an XA session not enrolled in a global transaction.         SessionDelegate sd = (SessionDelegate)mi.getTargetObject();         if (!state.isRecoverCalled())         {            if (trace) { log.trace("acknowledging NON-transactionally"); }                                    List acks = state.getToAck();                        // Sanity check            if (acks.size() != 1)            {               throw new IllegalStateException("Should only be one entry in list. " +                                               "There are " + acks.size());            }                        DeliveryInfo ack = (DeliveryInfo)acks.get(0);                        if (cancel)            {               List cancels = new ArrayList();               Cancel c = new Cancel(ack.getMessageProxy().getDeliveryId(), ack.getMessageProxy().getDeliveryCount());               cancels.add(c);               sd.cancelDeliveries(cancels);            }            else            {               sd.acknowledge(ack);            }                        //TODO we can optimise this for the auto_ack case (i.e. not store in list and have to clear each time)            state.getToAck().clear();         }         else         {            if (trace) { log.trace("recover called, so NOT acknowledging"); }            state.setRecoverCalled(false);         }      }      return null;   }