Buggy code:
public class KahaDBTransactionStore implements TransactionStore { static final Logger LOG = LoggerFactory . getLogger ( KahaDBTransactionStore . class ) ; ConcurrentHashMap < Object , KahaDBTransactionStore . Tx > inflightTransactions = new ConcurrentHashMap < Object , KahaDBTransactionStore . Tx > ( ) ; private final WireFormat wireFormat = new OpenWireFormat ( ) ; private final KahaDBStore theStore ; public KahaDBTransactionStore ( KahaDBStore theStore ) { } public class Tx { private final ArrayList < KahaDBTransactionStore . AddMessageCommand > messages = new ArrayList < KahaDBTransactionStore . AddMessageCommand > ( ) ; private final ArrayList < KahaDBTransactionStore . RemoveMessageCommand > acks = new ArrayList < KahaDBTransactionStore . RemoveMessageCommand > ( ) ; public void add ( KahaDBTransactionStore . AddMessageCommand msg ) { } public void add ( KahaDBTransactionStore . RemoveMessageCommand ack ) { } public Message [ ] getMessages ( ) { } public MessageAck [ ] getAcks ( ) { } public List < Future < Object > > commit ( ) throws IOException { } } public abstract class AddMessageCommand { private final ConnectionContext ctx ; AddMessageCommand ( ConnectionContext ctx ) { } abstract Message getMessage ( ) { } Future < Object > run ( ) throws IOException { } abstract Future < Object > run ( ConnectionContext ctx ) throws IOException { } } public abstract class RemoveMessageCommand { private final ConnectionContext ctx ; RemoveMessageCommand ( ConnectionContext ctx ) { } abstract MessageAck getMessageAck ( ) { } Future < Object > run ( ) throws IOException { } abstract Future < Object > run ( ConnectionContext context ) throws IOException { } } public MessageStore proxy ( MessageStore messageStore ) { } public TopicMessageStore proxy ( TopicMessageStore messageStore ) { } public void prepare ( TransactionId txid ) throws IOException { } public KahaDBTransactionStore . Tx getTx ( Object txid ) { } public void commit ( TransactionId txid , boolean wasPrepared , Runnable preCommit , Runnable postCommit ) throws IOException { } public void rollback ( TransactionId txid ) throws IOException { } protected void forgetRecoveredAcks ( TransactionId txid ) throws IOException { } public void start ( ) throws Exception { } public void stop ( ) throws Exception { } public synchronized void recover ( TransactionRecoveryListener listener ) throws IOException { } void addMessage ( ConnectionContext context , final MessageStore destination , final Message message ) throws IOException { } Future < Object > asyncAddQueueMessage ( ConnectionContext context , final MessageStore destination , final Message message ) throws IOException { } Future < Object > asyncAddTopicMessage ( ConnectionContext context , final MessageStore destination , final Message message ) throws IOException { } final void removeMessage ( ConnectionContext context , final MessageStore destination , final MessageAck ack ) throws IOException { } final void removeAsyncMessage ( ConnectionContext context , final MessageStore destination , final MessageAck ack ) throws IOException { if ( ack . isInTransaction ( ) ) { if ( ( ack . getTransactionId ( ) . isXATransaction ( ) ) || ( ( theStore . isConcurrentStoreAndDispatchTransactions ( ) ) == false ) ) { <START_BUG> destination . removeMessage ( context , ack ) ; <END_BUG> } else { KahaDBTransactionStore . Tx tx = getTx ( ack . getTransactionId ( ) ) ; tx . add ( new KahaDBTransactionStore . RemoveMessageCommand ( context ) { @ Override public MessageAck getMessageAck ( ) { return ack ; } @ Override public Future < Object > run ( ConnectionContext ctx ) throws IOException { destination . removeMessage ( ctx , ack ) ; return AbstractMessageStore . FUTURE ; } } ) ; } } else { destination . removeAsyncMessage ( context , ack ) ; } } final void acknowledge ( ConnectionContext context , final TopicMessageStore destination , final String clientId , final String subscriptionName , final MessageId messageId , final MessageAck ack ) throws IOException { } private KahaTransactionInfo getTransactionInfo ( TransactionId txid ) { } }

Fix:
destination . removeAsyncMessage ( context , ack ) ;