HHH-14326 Always close the connection even if releasing JDBC resources fails
Signed-off-by: Yoann Rodière <yoann@hibernate.org>
This commit is contained in:
parent
74433cdec3
commit
e5c830da19
|
@ -214,13 +214,17 @@ public class LogicalConnectionManagedImpl extends AbstractLogicalConnectionImple
|
||||||
throw new HibernateException( "Detected concurrent management of connection resources." +
|
throw new HibernateException( "Detected concurrent management of connection resources." +
|
||||||
" This might indicate a multi-threaded use of Hibernate in combination with managed resources, which is not supported." );
|
" This might indicate a multi-threaded use of Hibernate in combination with managed resources, which is not supported." );
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
try {
|
try {
|
||||||
getResourceRegistry().releaseResources();
|
getResourceRegistry().releaseResources();
|
||||||
if ( ! localVariableConnection.isClosed() ) {
|
if ( !localVariableConnection.isClosed() ) {
|
||||||
sqlExceptionHelper.logAndClearWarnings( localVariableConnection );
|
sqlExceptionHelper.logAndClearWarnings( localVariableConnection );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
jdbcConnectionAccess.releaseConnection( localVariableConnection );
|
jdbcConnectionAccess.releaseConnection( localVariableConnection );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (SQLException e) {
|
catch (SQLException e) {
|
||||||
throw sqlExceptionHelper.convert( e, "Unable to release JDBC Connection" );
|
throw sqlExceptionHelper.convert( e, "Unable to release JDBC Connection" );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue