You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when a component method is annotated with @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT), no event should be received from a code block annotated with @Transactional(propagation = Propagation.NOT_SUPPORTED)
I made a very small spring boot project that shows the issue:
2 Test methods in that project:
@Test public void notTransactional() --> WORKS OK (no transactional event is received) @Test public void notSupported() --> (KO: an event is received and it should not be because the block from witch the event is send is a propagation=NOT_SUPPORTED block)
Thanks for the sample, that is very helpful. I believe there is a faulty check in ApplicationListenerMethodTransactionalAdapter that relies on TransactionSynchronizationManager.isSynchronizationActive() to figure out if the current thread is running within a transaction. In the case of a NOT_SUPPORTED propagation type, this returns true so we should probably look at something else to drop the event.
@jhoeller wondering what our backport strategy for this one should be. Can be potentially annoying if users were relying on that side effect so I am tempted to fix this in 5.2 only. Thoughts?
snicoll
changed the title
@TransactionalEventListener issue
@TransactionalEventListener should not receive an event if no transaction is active
Jul 12, 2019
Alright, chatting with @jhoeller we discovered that SUPPORTS propagation type without an actual transaction triggers the event. It is likely that users may have relied on that faulty behaviour so let's fix that behaviour and clarify the Javadoc to specifically mention the fact an actual transaction is required.
when a component method is annotated with
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT)
, no event should be received from a code block annotated with@Transactional(propagation = Propagation.NOT_SUPPORTED)
I made a very small spring boot project that shows the issue:
2 Test methods in that project:
@Test public void notTransactional()
--> WORKS OK (no transactional event is received)@Test public void notSupported()
--> (KO: an event is received and it should not be because the block from witch the event is send is a propagation=NOT_SUPPORTED block)com.cbo.transac.zip
The text was updated successfully, but these errors were encountered: