When wrapping connections in a Transaction tag like: <sql:transaction dataSource="JNDI.DS"> <sql:query var="query1" > SELECT * from etc </sql:query> <sql:query var="query2" > SELECT * from etc </sql:query> </sql:transaction> The transaction tag causes a connection leak, the reason is as follows The nested connection correctly uses the parent connection object. The TransactionTagSupport class tries to close the connection in the doFinally() method, the problem is before the doFinally() tag is called the release() method is called which calls init() which sets the connection object to null and hence the doFinally() is unable to close the connection as there is no longer a reference to the object and hence the leak. Proposal would be to remove the init() method from the release() method. Environment: Weblogic 8.1 sp3 datasource is sybase looked up by jndi reference. class: org.apache.taglibs.standard.tag.common.sql.TransactionTagSupport
Looking at the code, I think a simpler approach would be to remove the conn = null; from init(). It's unnecessary as doFinally takes care of that.
FYI - I tried to reproduce this with Tomcat 5.5.20 and mysql using the jdbc connector, and failed -- behavior was as expected. This must be pretty specific to the JNDI driver, and I don't have a Sybase DB to test with. I did try preventing garbage collection on the connection, to no avail.
Created attachment 19543 [details] Fix Attached fix. From inspection, it's definitely a problem. The init() method is only called by the constructor and release(), so I've deleted the init() method. All of its statements are in the constructor, and two are then added to the release. There is also a bug concerning the isolation once the Connection bug is fixed. It won't get set back to the origIsolation but will always become TRANSACTION_NONE. So I've fixed that by adding it to the doFinally() rather than the release().
Applying fix: svn ci -m "Applying fix from 34896" src/ Sending src/org/apache/taglibs/standard/tag/common/sql/TransactionTagSupport.java Transmitting file data . Committed revision 504780. Need to make sure nothing has been broken in the standard-examples (or in your attempted reproduction Bjorn?) before closing as FIXED.
Henri, your fix does not change the behavior of my attempted repro, so I don't think it broke anything. :)