Buggy code:
public class TransactionContext implements XAResource { public static final String xaErrorCodeMarker = "xaErrorCode:" ; private static final Logger LOG = LoggerFactory . getLogger ( TransactionContext . class ) ; private static final HashMap < TransactionId , List < TransactionContext > > ENDED_XA_TRANSACTION_CONTEXTS = new HashMap < TransactionId , List < TransactionContext > > ( ) ; private ActiveMQConnection connection ; private final LongSequenceGenerator localTransactionIdGenerator ; private List < Synchronization > synchronizations ; private Xid associatedXid ; private TransactionId transactionId ; private LocalTransactionEventListener localTransactionEventListener ; private int beforeEndIndex ; private volatile boolean rollbackOnly ; public TransactionContext ( ) { } public TransactionContext ( ActiveMQConnection connection ) { } public boolean isInXATransaction ( ) { } public void setRollbackOnly ( boolean val ) { } public boolean isInLocalTransaction ( ) { } public boolean isInTransaction ( ) { } public LocalTransactionEventListener getLocalTransactionEventListener ( ) { } public void setLocalTransactionEventListener ( LocalTransactionEventListener localTransactionEventListener ) { } public void addSynchronization ( Synchronization s ) { } private void afterRollback ( ) throws JMSException { } private void afterCommit ( ) throws JMSException { } private void beforeEnd ( ) throws JMSException { } public TransactionId getTransactionId ( ) { } public void begin ( ) throws JMSException { } public void rollback ( ) throws JMSException { } public void commit ( ) throws JMSException { if ( isInXATransaction ( ) ) { throw new TransactionInProgressException ( "Cannot<seq2seq4repair_space>commit()<seq2seq4repair_space>if<seq2seq4repair_space>an<seq2seq4repair_space>XA<seq2seq4repair_space>transaction<seq2seq4repair_space>is<seq2seq4repair_space>already<seq2seq4repair_space>in<seq2seq4repair_space>progress<seq2seq4repair_space>" ) ; } try { beforeEnd ( ) ; } catch ( JMSException e ) { rollback ( ) ; throw e ; } <START_BUG> if ( rollbackOnly ) { <END_BUG> final String message = ( "Commit<seq2seq4repair_space>of<seq2seq4repair_space>" + ( transactionId ) ) + "<seq2seq4repair_space>failed<seq2seq4repair_space>due<seq2seq4repair_space>to<seq2seq4repair_space>rollback<seq2seq4repair_space>only<seq2seq4repair_space>request;<seq2seq4repair_space>typically<seq2seq4repair_space>due<seq2seq4repair_space>to<seq2seq4repair_space>failover<seq2seq4repair_space>with<seq2seq4repair_space>pending<seq2seq4repair_space>acks" ; try { rollback ( ) ; } finally { TransactionContext . LOG . warn ( message ) ; throw new TransactionRolledBackException ( message ) ; } } if ( ( transactionId ) != null ) { TransactionContext . LOG . debug ( "Commit:<seq2seq4repair_space>{}<seq2seq4repair_space>syncCount:<seq2seq4repair_space>{}" , transactionId , ( ( synchronizations ) != null ? synchronizations . size ( ) : 0 ) ) ; TransactionInfo info = new TransactionInfo ( getConnectionId ( ) , transactionId , TransactionInfo . COMMIT_ONE_PHASE ) ; this . transactionId = null ; try { syncSendPacketWithInterruptionHandling ( info ) ; if ( ( localTransactionEventListener ) != null ) { localTransactionEventListener . commitEvent ( ) ; } afterCommit ( ) ; } catch ( JMSException cause ) { TransactionContext . LOG . info ( "commit<seq2seq4repair_space>failed<seq2seq4repair_space>for<seq2seq4repair_space>transaction<seq2seq4repair_space>{}" , info . getTransactionId ( ) , cause ) ; if ( ( localTransactionEventListener ) != null ) { localTransactionEventListener . rollbackEvent ( ) ; } afterRollback ( ) ; throw cause ; } } } @ Override public void start ( Xid xid , int flags ) throws XAException { } private ConnectionId getConnectionId ( ) { } @ Override public void end ( Xid xid , int flags ) throws XAException { } private boolean equals ( Xid xid1 , Xid xid2 ) { } @ Override public int prepare ( Xid xid ) throws XAException { } @ Override public void rollback ( Xid xid ) throws XAException { } @ Override public void commit ( Xid xid , boolean onePhase ) throws XAException { } @ Override public void forget ( Xid xid ) throws XAException { } @ Override public boolean isSameRM ( XAResource xaResource ) throws XAException { } @ Override public Xid [ ] recover ( int flag ) throws XAException { } @ Override public int getTransactionTimeout ( ) throws XAException { } @ Override public boolean setTransactionTimeout ( int seconds ) throws XAException { } protected String getResourceManagerId ( ) throws JMSException { } private void setXid ( Xid xid ) throws XAException { } private void disassociate ( ) { } private Response syncSendPacketWithInterruptionHandling ( Command command ) throws JMSException { } private XAException toXAException ( JMSException e ) { } private int parseFromMessageOr ( String message , int fallbackCode ) { } public ActiveMQConnection getConnection ( ) { } public ActiveMQConnection setConnection ( ActiveMQConnection connection ) { } public void cleanup ( ) { } @ Override public String toString ( ) { } }

Fix:
if ( ( ( transactionId ) != null ) && ( rollbackOnly ) ) {