Hi i wanted to implement long running conversations (between multiple HTTP requests) and i translated the HibernateSessionConversationFilter
to a JSF phase event listener.
(too bad i am not using SEAM but that's another story).
But after reading the code i am wondering if there aren't any issues with exception handling in the given example.
For instance, the following code is executed when a Throwable is thrown:
Code:
log.debug("Unbinding Session after exception");
currentSession = ManagedSessionContext.unbind(sf);
log.debug("Closing Session after exception");
currentSession.close();
The problem is that the current session is already unbound (in the code) after filter chaining but before committing the transaction. Therefore currentSession returns null and NPE occurs.
Also sessionFactory.getCurrentSession() is executed in exception handling code which should throw a SessionException since in the CurrentSessionContextImpl the session is already unbound for the current thread.
Please let me know, if you already noticed this issue.
Thanks,
Luc