Buggy code:
public class StatefulSessionSynchronizationInterceptor extends AbstractEJBInterceptor { private final boolean containerManagedTransactions ; private static final StatefulSessionSynchronizationInterceptor . Factory CONTAINER_MANAGED = new StatefulSessionSynchronizationInterceptor . Factory ( TransactionManagementType . CONTAINER ) ; private static final StatefulSessionSynchronizationInterceptor . Factory BEAN_MANAGED = new StatefulSessionSynchronizationInterceptor . Factory ( TransactionManagementType . BEAN ) ; public static InterceptorFactory factory ( final TransactionManagementType type ) { } public StatefulSessionSynchronizationInterceptor ( final boolean containerManagedTransactions ) { } @ Override public Object processInvocation ( final InterceptorContext context ) throws Exception { final StatefulSessionComponent component = getComponent ( context , StatefulSessionComponent . class ) ; final StatefulSessionComponentInstance instance = StatefulComponentInstanceInterceptor . getComponentInstance ( context ) ; final OwnableReentrantLock lock = instance . getLock ( ) ; final Object threadLock = instance . getThreadLock ( ) ; final TransactionSynchronizationRegistry transactionSynchronizationRegistry = component . getTransactionSynchronizationRegistry ( ) ; final Object lockOwner = StatefulSessionSynchronizationInterceptor . getLockOwner ( transactionSynchronizationRegistry ) ; lock . pushOwner ( lockOwner ) ; try { final AccessTimeoutDetails timeout = component . getAccessTimeout ( context . getMethod ( ) ) ; if ( ROOT_LOGGER . isTraceEnabled ( ) ) { ROOT_LOGGER . trace ( ( ( ( ( ( "Trying<seq2seq4repair_space>to<seq2seq4repair_space>acquire<seq2seq4repair_space>lock:<seq2seq4repair_space>" + lock ) + "<seq2seq4repair_space>for<seq2seq4repair_space>stateful<seq2seq4repair_space>component<seq2seq4repair_space>instance:<seq2seq4repair_space>" ) + instance ) + "<seq2seq4repair_space>during<seq2seq4repair_space>invocation:<seq2seq4repair_space>" ) + context ) ) ; } boolean acquired = lock . tryLock ( timeout . getValue ( ) , timeout . getTimeUnit ( ) ) ; if ( ! acquired ) { throw EjbLogger . ROOT_LOGGER . failToObtainLock ( context , timeout . getValue ( ) , timeout . getTimeUnit ( ) ) ; } synchronized ( threadLock ) { if ( ROOT_LOGGER . isTraceEnabled ( ) ) { ROOT_LOGGER . trace ( ( ( ( ( ( "Acquired<seq2seq4repair_space>lock:<seq2seq4repair_space>" + lock ) + "<seq2seq4repair_space>for<seq2seq4repair_space>stateful<seq2seq4repair_space>component<seq2seq4repair_space>instance:<seq2seq4repair_space>" ) + instance ) + "<seq2seq4repair_space>during<seq2seq4repair_space>invocation:<seq2seq4repair_space>" ) + context ) ) ; } Object currentTransactionKey = null ; boolean wasTxSyncRegistered = false ; try { if ( containerManagedTransactions ) { if ( ! ( instance . isSynchronizationRegistered ( ) ) ) { currentTransactionKey = transactionSynchronizationRegistry . getTransactionKey ( ) ; final int status = transactionSynchronizationRegistry . getTransactionStatus ( ) ; <START_BUG> if ( ( ( currentTransactionKey != null ) && ( status != ( Status . STATUS_COMMITTED ) ) ) && ( status != ( Status . STATUS_ROLLEDBACK ) ) ) { <END_BUG> final Synchronization statefulSessionSync = new StatefulSessionSynchronizationInterceptor . StatefulSessionSynchronization ( instance , lockOwner ) ; transactionSynchronizationRegistry . registerInterposedSynchronization ( statefulSessionSync ) ; wasTxSyncRegistered = true ; if ( ROOT_LOGGER . isTraceEnabled ( ) ) { ROOT_LOGGER . trace ( ( ( ( ( ( "Registered<seq2seq4repair_space>tx<seq2seq4repair_space>synchronization:<seq2seq4repair_space>" + statefulSessionSync ) + "<seq2seq4repair_space>for<seq2seq4repair_space>tx:<seq2seq4repair_space>" ) + currentTransactionKey ) + "<seq2seq4repair_space>associated<seq2seq4repair_space>with<seq2seq4repair_space>stateful<seq2seq4repair_space>component<seq2seq4repair_space>instance:<seq2seq4repair_space>" ) + instance ) ) ; } instance . afterBegin ( ) ; instance . setSynchronizationRegistered ( true ) ; context . putPrivateData ( StatefulTransactionMarker . class , StatefulTransactionMarker . of ( true ) ) ; } } else { context . putPrivateData ( StatefulTransactionMarker . class , StatefulTransactionMarker . of ( false ) ) ; } } return context . proceed ( ) ; } finally { if ( ( ! wasTxSyncRegistered ) && ( ! ( instance . isSynchronizationRegistered ( ) ) ) ) { releaseInstance ( instance ) ; } else if ( ! wasTxSyncRegistered ) { releaseLock ( instance ) ; if ( ! ( instance . isDiscarded ( ) ) ) { instance . getComponent ( ) . getCache ( ) . release ( instance ) ; } } } } } finally { lock . popOwner ( ) ; } } private static Object getLockOwner ( final TransactionSynchronizationRegistry transactionSynchronizationRegistry ) { } void releaseInstance ( final StatefulSessionComponentInstance instance ) { } void releaseLock ( final StatefulSessionComponentInstance instance ) { } private static class Factory extends ComponentInstanceInterceptorFactory { private final TransactionManagementType type ; public Factory ( final TransactionManagementType type ) { } @ Override protected Interceptor create ( final Component component , final InterceptorFactoryContext context ) { } } private class StatefulSessionSynchronization implements Synchronization { private final StatefulSessionComponentInstance statefulSessionComponentInstance ; private final Object lockOwner ; StatefulSessionSynchronization ( StatefulSessionComponentInstance statefulSessionComponentInstance , final Object lockOwner ) { } @ Override public void beforeCompletion ( ) { } @ Override public void afterCompletion ( int status ) { } private void handleThrowable ( Throwable t ) { } } }

Fix:
if ( ( currentTransactionKey != null ) && ( status != ( Status . STATUS_COMMITTED ) ) ) {