Project: Tomcat
Bug 53523 rollbackOnReturn/commitOnReturn does not work without defaultAutoCommit=false
Reported: 2012-07-09 11:21:38 | Status: resolved wontfix

Hi, The properties rollbackOnReturn and commitOnReturn, which are critical for cleaning up connections after they are used and returned to the pool, does not work when the defaultAutoCommit property is not set or when it is set to true. The code segment at ConnectionPool class has this, protected boolean terminateTransaction(PooledConnection con) { try { if (con.getPoolProperties().getDefaultAutoCommit()==Boolean.FALSE) { .... The full logic is wrapped in that first if statement, and as I see, that is not correct. Because, the actual default auto commit value when we don't set this property can either be autoCommit true or false, which depends on the database driver. And also, even when we have a default setting provided, the user has the freedom to change the autoCommit flag to either true or false at the beginning when they get the connection from the pool. So we should not be reading the pool properties in this place, but just check the current live connection's autoCommit value and act accordingly. So I suppose the fix should be to simply remove the outer if statement. Cheers, Anjana.

Files changed in fix:
modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolConfiguration.java