Merge pull request #450 from nitincchauhan/dev

init 'other' vars too for proxy connection
pull/451/merge
Brett Wooldridge 10 years ago
commit 316629b72f

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

@ -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, hikariPool.isAutoCommit());
return ProxyFactory.getProxyConnection(this, connection, openStatements, leakTask, now, hikariPool.getReadOnly(), hikariPool.getAutoCommit());
}
void resetConnectionState(final ProxyConnection proxyConnection, final int dirtyBits) throws SQLException

@ -55,19 +55,19 @@ public abstract class ProxyConnection implements Connection
protected Connection delegate;
private final ProxyLeakTask leakTask;
private final PoolEntry poolEntry;
private final ProxyLeakTask leakTask;
private final FastList<Statement> openStatements;
private int dirtyBits;
private long lastAccess;
private boolean isCommitStateDirty;
protected boolean isAutoCommit;
private boolean isReadOnly;
private boolean isAutoCommit;
private int networkTimeout;
private int transactionIsolation;
private String dbcatalog;
private boolean isReadOnly;
// static initializer
static {
@ -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, final boolean isAutoCommit) {
protected ProxyConnection(final PoolEntry poolEntry, final Connection connection, final FastList<Statement> openStatements, final ProxyLeakTask leakTask, final long now, final boolean isReadOnly, final boolean isAutoCommit) {
this.poolEntry = poolEntry;
this.delegate = connection;
this.openStatements = openStatements;
this.leakTask = leakTask;
this.lastAccess = now;
this.isReadOnly = isReadOnly;
this.isAutoCommit = isAutoCommit;
}
@ -227,7 +228,7 @@ public abstract class ProxyConnection implements Connection
leakTask.cancel();
try {
if (isCommitStateDirty && !isAutoCommit) {
if (isCommitStateDirty && !isAutoCommit && !isReadOnly) {
delegate.rollback();
lastAccess = clockSource.currentTime();
LOGGER.debug("{} - Executed rollback on connection {} due to dirty commit state on close().", poolEntry.getPoolName(), delegate);

@ -39,15 +39,16 @@ public final class ProxyFactory
/**
* Create a proxy for the specified {@link Connection} instance.
* @param openStatements
* @param connection
*
* @param connectionState the PoolBagEntry entry for this proxy
* @param openStatements a leak detetection task
* @param now current timestamp in milliseconds
* @param poolEntry
* @param connection
* @param openStatements
* @param leakTask
* @param now
* @param isReadOnly
* @param isAutoCommit
* @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, final boolean isAutoCommit)
static ProxyConnection getProxyConnection(final PoolEntry poolEntry, final Connection connection, final FastList<Statement> openStatements, final ProxyLeakTask leakTask, final long now, final boolean isReadOnly, 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