History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: HHH-1669
Type: Bug Bug
Status: Closed Closed
Resolution: Duplicate
Priority: Major Major
Assignee: Unassigned
Reporter: julio rincon
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Hibernate3

TransactionHelper leaves JDBC connections unclosed, when the connection is set to autocommit false

Created: 14/Apr/06 06:03 AM   Updated: 06/Jun/06 12:29 PM
Component/s: core
Affects Version/s: 3.2.0 cr1
Fix Version/s: None

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown
Environment: Hibernate 3.2.0 CR1


 Description  « Hide
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.

 All   Comments   Work Log   Change History   FishEye      Sort Order:
Bulto - [06/Jun/06 11:14 AM ]
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]