In JdbcTransaction, rollback should always close a connection even if the rollback results in an exception.
Current Code:
/** * Rollback the transaction. * If there is a throwable it is logged as the cause in the transaction log. */ public void rollback(Throwable cause) throws PersistenceException { if (!isActive()) { throw new IllegalStateException(illegalStateMessage); } try { connection.rollback();
// these will not throw an exception deactivate(); notifyRollback(cause); } catch (Exception ex) { throw new PersistenceException(ex); } }
Proposed Code:
/** * Rollback the transaction. If there is a throwable it is logged as the cause * in the transaction log. */ public void rollback(Throwable cause) throws PersistenceException { if (!isActive()) { throw new IllegalStateException(illegalStateMessage); }
PersistenceException e = null; try { connection.rollback(); } catch (Exception ex) { e = new PersistenceException(ex); }
// these will not throw an exception deactivate(); if (e == null) notifyRollback(cause);
if (e != null) throw e; }