From 5e1a485f4e77687d78eae98839125a6023eb2b92 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Thu, 31 Jul 2008 15:10:43 +0000 Subject: [PATCH] HHH-2604 : Isolator.JdbcDelegate connection releasing git-svn-id: https://svn.jboss.org/repos/hibernate/core/branches/Branch_3_2@14999 1b8cb986-b30d-0410-93ca-fae66ebed9b2 --- .../engine/transaction/Isolater.java | 16 +++++++------ src/org/hibernate/jdbc/AbstractBatcher.java | 24 +++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/org/hibernate/engine/transaction/Isolater.java b/src/org/hibernate/engine/transaction/Isolater.java index a9e80fd05d..ecacd8efa9 100644 --- a/src/org/hibernate/engine/transaction/Isolater.java +++ b/src/org/hibernate/engine/transaction/Isolater.java @@ -215,15 +215,17 @@ public class Isolater { } } finally { - if ( transacted && wasAutoCommit ) { - try { - connection.setAutoCommit( true ); - } - catch( Throwable ignore ) { - log.trace( "was unable to reset connection back to auto-commit" ); + if ( connection != null ) { + if ( transacted && wasAutoCommit ) { + try { + connection.setAutoCommit( true ); + } + catch( Throwable ignore ) { + log.trace( "was unable to reset connection back to auto-commit" ); + } } + session.getBatcher().closeConnection( connection ); } - session.getBatcher().closeConnection( connection ); } } } diff --git a/src/org/hibernate/jdbc/AbstractBatcher.java b/src/org/hibernate/jdbc/AbstractBatcher.java index 6a5ff17ce3..a9da4abcd5 100644 --- a/src/org/hibernate/jdbc/AbstractBatcher.java +++ b/src/org/hibernate/jdbc/AbstractBatcher.java @@ -590,26 +590,24 @@ public abstract class AbstractBatcher implements Batcher { } public void closeConnection(Connection conn) throws HibernateException { + if ( conn == null ) { + log.debug( "found null connection on AbstractBatcher#closeConnection" ); + // EARLY EXIT!!!! + return; + } + if ( log.isDebugEnabled() ) { - log.debug( - "closing JDBC connection" + - preparedStatementCountsToString() + - resultSetCountsToString() - ); + log.debug( "closing JDBC connection" + preparedStatementCountsToString() + resultSetCountsToString() ); } try { if ( !conn.isClosed() ) { - JDBCExceptionReporter.logAndClearWarnings(conn); + JDBCExceptionReporter.logAndClearWarnings( conn ); } - factory.getConnectionProvider().closeConnection(conn); + factory.getConnectionProvider().closeConnection( conn ); } - catch (SQLException sqle) { - throw JDBCExceptionHelper.convert( - factory.getSQLExceptionConverter(), - sqle, - "Cannot close connection" - ); + catch ( SQLException sqle ) { + throw JDBCExceptionHelper.convert( factory.getSQLExceptionConverter(), sqle, "Cannot close connection" ); } }