Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There is a really obscure (and usually already fatal) error condition
where during handle creation, the connection object becomes no longer
viable (e.g. the database crashes, the connection gets closed). In that
case, either
transactionHandler.specialize()
ortransactionHandler.isInTransaction()
will throw a SQLException (or aruntime exception) and the cleanup handler for the connection is never
added. Technically, the handle will there leak the connection (which is
already non-viable because it caused the exception in the first
place). This fix moves the cleanup before calling the methods which will
ensure that the connection will be cleaned up in every situation.
This may change user visible behavior slightly; instead of a
SQLException, it is possible that now a
ConnectionException
with theroot exception attached is now observed. This is unlikely but possible.