SessionFactoryObserver#sessionFactoryClosing() gets called after the session factory is marked as closed

Description

In Hibernate Search, we are using a SessionFactoryObserver in order to stop running background processes that rely on the SessionFactory before it gets closed, because otherwise those process would start failing.

However, it appears that when sessionFactoryClosing() gets called, SessionFactory#isClosed() already returns @code true. It seems the factory becomes unusable sometime before sessionFactoryClosing() gets called.

Queries relying on existing sessions, in particular, will start failing right when SessionFactory.close() gets called, before sessionFactoryClosing() gets executed and gets a chance to stop background processes.

This contradicts the javadoc of sessionFactoryClosing():

Callback to indicate that the given factory is about to close. The passed factory reference should be usable since it is only about to close.

Activity

Show:
Andrea Boriero
changed the StatusMay 12, 2021 at 3:50 PM
Resolved
Closed
Andrea Boriero
updated the Fix versionsMay 12, 2021 at 2:25 PM
5.4.32
None
Andrea Boriero
changed the StatusMay 12, 2021 at 2:25 PM
In Progress
Resolved
Andrea Boriero
updated the ResolutionMay 12, 2021 at 2:25 PM
None
Fixed
Yoann Rodière
updated the Fix versionsMay 3, 2021 at 10:12 AM
None
5.4.32
Yoann Rodière
changed the StatusApril 30, 2021 at 12:47 PM
Open
In Progress
Yoann Rodière
changed the AssigneeApril 30, 2021 at 12:47 PM
Unassigned
Yoann Rodière
Yoann Rodière
updated the Pull RequestApril 30, 2021 at 12:47 PM
None
https://github.com/hibernate/hibernate-orm/pull/3952
Yoann Rodière
updated the Fix versionsApril 30, 2021 at 12:47 PM
5.4-backlog
None
Yoann Rodière
updated the Fix versionsApril 30, 2021 at 12:47 PM
None
5.5.0.Alpha2
Yoann Rodière
updated the LinkApril 30, 2021 at 12:31 PM
None
This issue follows up on HHH-10674
Yoann Rodière
created the IssueMarch 30, 2021 at 11:56 AM
Fixed

Details

Assignee

Reporter

Fix versions

Affects versions

Priority

Created March 30, 2021 at 11:56 AM
Updated May 12, 2021 at 3:50 PM
Resolved May 12, 2021 at 2:25 PM