Brett Meyer commented on Bug HHH-7910

When the transaction times out, the reaper calls afterCompletion with a normal STATUS_ROLLEDBACK status. This is the same status that would be received during a "normal" transaction rollback, including one triggered by an application. Hibernate does not keep track of which thread "owns" a session (and to do so wouldn't be a good idea). Further, there is no extra information coming from the reaper's calls that would identify it as so.

In afterCompletion, we could set a synchronized flag if the session gets cleared. If set, the assertionfailure "unsafe" exception would either be different or not thrown at all. However, we're voting not to do this – it makes too many assumptions. Like I mentioned, afterCompletion gets called by "normal" rollbacks. Since we have no way of knowing whether or not the reaper is the caller, the flag would always be set by a rollback of any kind. And it also assumes that an EntityEntry can be null in the PersistenceContext solely due this condition (which is certainly not the case).

We think the assertion failure is the correct one. However, we could change the text a bit to indicate that it's due to unsafe access or this condition. I agree that the message is currently misleading and may cause users to think their app is doing something wrong in another thread.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira