SessionFactoryObserver#sessionFactoryClosing() gets called after the session factory is marked as closed
Description
Activity
Show:
Andrea Boriero
changed the StatusMay 12, 2021 at 3:50 PMResolved
Closed
Andrea Boriero
updated the Fix versionsMay 12, 2021 at 2:25 PM5.4.32
None
Andrea Boriero
changed the StatusMay 12, 2021 at 2:25 PMIn Progress
Resolved
Andrea Boriero
updated the ResolutionMay 12, 2021 at 2:25 PMNone
Fixed
Yoann Rodière
updated the Fix versionsMay 3, 2021 at 10:12 AMNone
5.4.32
Yoann Rodière
changed the StatusApril 30, 2021 at 12:47 PMOpen
In Progress
Yoann Rodière
changed the AssigneeApril 30, 2021 at 12:47 PMUnassigned
Yoann Rodière
Yoann Rodière
updated the Pull RequestApril 30, 2021 at 12:47 PMNone
https://github.com/hibernate/hibernate-orm/pull/3952
Yoann Rodière
updated the Fix versionsApril 30, 2021 at 12:47 PM5.4-backlog
None
Yoann Rodière
updated the Fix versionsApril 30, 2021 at 12:47 PMNone
5.5.0.Alpha2
Yoann Rodière
updated the LinkApril 30, 2021 at 12:31 PMNone
This issue follows up on HHH-10674
Yoann Rodière
created the IssueMarch 30, 2021 at 11:56 AMFixed
Details
Details
Assignee
Yoann Rodière
Yoann RodièreReporter
Yoann Rodière
Yoann RodièreFix 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
In Hibernate Search, we are using a
SessionFactoryObserver
in order to stop running background processes that rely on theSessionFactory
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 beforesessionFactoryClosing()
gets called.Queries relying on existing sessions, in particular, will start failing right when
SessionFactory.close()
gets called, beforesessionFactoryClosing()
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.