Skip to content

Commit e5c830d

Browse files
yrodiereSanne
authored andcommitted
HHH-14326 Always close the connection even if releasing JDBC resources fails
Signed-off-by: Yoann Rodière <[email protected]>
1 parent 74433cd commit e5c830d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

hibernate-core/src/main/java/org/hibernate/resource/jdbc/internal/LogicalConnectionManagedImpl.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,15 @@ private void releaseConnection() {
215215
" This might indicate a multi-threaded use of Hibernate in combination with managed resources, which is not supported." );
216216
}
217217
try {
218-
getResourceRegistry().releaseResources();
219-
if ( ! localVariableConnection.isClosed() ) {
220-
sqlExceptionHelper.logAndClearWarnings( localVariableConnection );
218+
try {
219+
getResourceRegistry().releaseResources();
220+
if ( !localVariableConnection.isClosed() ) {
221+
sqlExceptionHelper.logAndClearWarnings( localVariableConnection );
222+
}
223+
}
224+
finally {
225+
jdbcConnectionAccess.releaseConnection( localVariableConnection );
221226
}
222-
jdbcConnectionAccess.releaseConnection( localVariableConnection );
223227
}
224228
catch (SQLException e) {
225229
throw sqlExceptionHelper.convert( e, "Unable to release JDBC Connection" );

0 commit comments

Comments
 (0)