ENT-2489: Gracefully handle session that might have already been closed. (#3933)

This commit is contained in:
Viktor Kolomeyko 2018-09-13 09:16:24 +01:00 committed by GitHub
parent 057ee74611
commit 0c1910722b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -58,8 +58,11 @@ class ArtemisMessagingClient(private val config: MutualSslConfiguration,
override fun stop() = synchronized(this) {
started?.run {
producer.close()
// Ensure any trailing messages are committed to the journal
session.commit()
// Since we are leaking the session outside of this class it may well be already closed.
if(!session.isClosed) {
// Ensure any trailing messages are committed to the journal
session.commit()
}
// Closing the factory closes all the sessions it produced as well.
sessionFactory.close()
}