Title: Message Title
| |
|
|
I mean this:
{code:java} /** * Invoked when the transaction has been committed or rolled back. * * @param status the status of the transaction. */ private void afterCompletion(int status) { if (synchronizationObserver != null) { LOGGER.info(() -> String.format("notifying after completion - %s", status)); synchronizationObserver.afterCompletion(status); LOGGER.info("after completion notified"); }
// if not cleared, we get an infinite loop when an event is fired during a transaction synchronizationObserver = null; } {code}
This method is extracted from my implementation of UserTransaction, and is invoked after a transaction is committed or rolled back. If I do not set the synchronization observer to null, and a transactional observer starts a transaction, I get either the problem I've reported here or an infinite loop where the same event is fired again and again, depending on whether transactional observer is executed on the current thread or scheduled for a deferred execution.
The reason for this is as follows: * The synchronization observer is set when an event is fired, and its implementation contains both the event and the list of observers to be notified before and after the transaction has completed. * If the transactional observer starts a transaction but does not fire itself an event, the synchronization observer that was previously set remains unchanged: it still contains the same event, and the same list of observers to notify. It is invoked again when the transaction started by the transactional observer is committed or rolled back, hence the infinite loop or the problem I've reported here. |
|
|
|
| |
|
|
_______________________________________________
weld-issues mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/weld-issues