hibernate/hibernate-orm — pull request #320 by gbadner (2012-04-27 09:41:52+00:00)
Title: HHH-7265 : ConcurrentModificationException in SynchronizationRegistryImp.l.notifySynchronizationsAfterTransactionCompletion

This pull request removes the synchronization that gets registered by EntityManagerImpl.close(). Instead the synchronization will be added by AbstractEntityManagerImpl$AfterCompletionActionImpl.doAction() if the session is still open, but the entity manager is closed. Adding the synchronization here should ensure that it's the last afterCompletion synchronization that closes the session.

It would be tidier if AfterCompletionAction had something like "doAfterAfterCompletionAction" that simply closed the session (rather than relying on a synchronization to do it).

See documentation in the pull request code for more info.