Fix bug uncovered during live DB testing. If the database is autoCommit=true we were trying to rollback because ProxyConnection.isAutoCommit was never initialized to true.

pull/451/merge
Brett Wooldridge 9 years ago
parent 476180b0bc
commit e74639c418

@ -157,6 +157,11 @@ abstract class PoolBase
return lastConnectionFailure.getAndSet(null);
}
boolean isAutoCommit()
{
return isAutoCommit;
}
public DataSource getUnwrappedDataSource()
{
return dataSource;
@ -171,6 +176,11 @@ abstract class PoolBase
return new PoolEntry(newConnection(), this);
}
public void initConnectionState(ProxyConnection proxyConnection)
{
proxyConnection.isAutoCommit = isAutoCommit;
}
void resetConnectionState(final Connection connection, final ProxyConnection proxyConnection, final int dirtyBits) throws SQLException
{
int resetBits = 0;

@ -90,7 +90,7 @@ final class PoolEntry implements IConcurrentBagEntry
Connection createProxyConnection(final ProxyLeakTask leakTask, final long now)
{
return ProxyFactory.getProxyConnection(this, connection, openStatements, leakTask, now);
return ProxyFactory.getProxyConnection(this, connection, openStatements, leakTask, now, hikariPool.isAutoCommit());
}
void resetConnectionState(final ProxyConnection proxyConnection, final int dirtyBits) throws SQLException

@ -63,7 +63,7 @@ public abstract class ProxyConnection implements Connection
private long lastAccess;
private boolean isCommitStateDirty;
private boolean isAutoCommit;
protected boolean isAutoCommit;
private int networkTimeout;
private int transactionIsolation;
private String dbcatalog;
@ -83,12 +83,13 @@ public abstract class ProxyConnection implements Connection
SQL_ERRORS.add("JZ0C1"); // Sybase disconnect error
}
protected ProxyConnection(final PoolEntry poolEntry, final Connection connection, final FastList<Statement> openStatements, final ProxyLeakTask leakTask, final long now) {
protected ProxyConnection(final PoolEntry poolEntry, final Connection connection, final FastList<Statement> openStatements, final ProxyLeakTask leakTask, final long now, final boolean isAutoCommit) {
this.poolEntry = poolEntry;
this.delegate = connection;
this.openStatements = openStatements;
this.leakTask = leakTask;
this.lastAccess = now;
this.isAutoCommit = isAutoCommit;
}
/** {@inheritDoc} */

@ -47,7 +47,7 @@ public final class ProxyFactory
* @param now current timestamp in milliseconds
* @return a proxy that wraps the specified {@link Connection}
*/
static ProxyConnection getProxyConnection(final PoolEntry poolEntry, final Connection connection, final FastList<Statement> openStatements, final ProxyLeakTask leakTask, final long now)
static ProxyConnection getProxyConnection(final PoolEntry poolEntry, final Connection connection, final FastList<Statement> openStatements, final ProxyLeakTask leakTask, final long now, final boolean isAutoCommit)
{
// Body is replaced (injected) by JavassistProxyFactory
throw new IllegalStateException("You need to run the CLI build and you need target/classes in your classpath to run.");

Loading…
Cancel
Save