I mean this:
/** |
* 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; |
}
|
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 transaction observer is executed on the current thread or scheduled for a deferred execution. |