The Isolater.JdbcDelegate class's delegateWork(...) method leaves the JDBC Connection open causing a lekage. Specifically, the connection is left open only when the Connection was set to autocommit false.
The escenario in which the problem is experienced is when a TransactionHelper subclass is implemented for instance to generate custom identifiers, the TransactionHelper provides the doWorkInNewTransaction method to ensure that the ID generation is done in a separate transaction and always commited. The mentioned method uses the Isolater class for this purpose.
This is the patch:
Index: src/org/hibernate/engine/transaction/Isolater.java
===================================================================
— src/org/hibernate/engine/transaction/Isolater.java (revision 9747)
+++ src/org/hibernate/engine/transaction/Isolater.java (working copy)
@@ -185,9 +185,9 @@
}
catch( Throwable ignore ) {
log.trace( "was unable to reset connection back to auto-commit" );
- }
- session.getBatcher().closeConnection( connection );
+ }
}
+ session.getBatcher().closeConnection( connection );
}
}
}
Cheers
Julio.
Hello,
It's a serious bug.
ligne 181 :
[code]
finally {
if ( wasAutoCommit ) {
try { connection.setAutoCommit( true ); }
catch( Throwable ignore ) { log.trace( "was unable to reset connection back to auto-commit" ); }
session.getBatcher().closeConnection( connection );
}
}
[/code]
The connection is closed only if it was AutoCommit. Hibernate must always close the connection.
The correct code :
[code]
finally {
if ( wasAutoCommit ) {
try { connection.setAutoCommit( true ); } }
catch( Throwable ignore ) { log.trace( "was unable to reset connection back to auto-commit" ); }
}
session.getBatcher().closeConnection( connection );
}
[/code]