Affects: spring-tx 5.3.31

I have a strange behaviour in my method annotated with @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) I would expect that method to be called with no transaction open. But TransactionSynchronizationManager.isActualTransactionActive() returns true.

I tracked it down to the triggerAfterCompletion in the class AbstractPlatformTransactionManager and there to the lines

            if (!status.hasTransaction() || status.isNewTransaction()) {
                // No transaction or new transaction for the current scope ->
                // invoke the afterCompletion callbacks immediately
                invokeAfterCompletion(synchronizations, completionStatus);
            }

Could it be that the second should be negated?

            if (!status.hasTransaction() && !status.isNewTransaction()) {

The comment could suggest that if i understand correctly.

Comment From: snicoll

This is the expected behavior, please review the Javadoc of AFTER_COMMITand TransactionSynchronization#afterCommit() that it links to.

Comment From: BrunoEberhard

Sorry for not seeing the note.