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); return lastConnectionFailure.getAndSet(null);
} }
boolean isAutoCommit()
{
return isAutoCommit;
}
public DataSource getUnwrappedDataSource() public DataSource getUnwrappedDataSource()
{ {
return dataSource; return dataSource;
@ -176,9 +171,14 @@ abstract class PoolBase
return new PoolEntry(newConnection(), this); 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 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) 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 void resetConnectionState(final ProxyConnection proxyConnection, final int dirtyBits) throws SQLException

@ -55,19 +55,19 @@ public abstract class ProxyConnection implements Connection
protected Connection delegate; protected Connection delegate;
private final ProxyLeakTask leakTask;
private final PoolEntry poolEntry; private final PoolEntry poolEntry;
private final ProxyLeakTask leakTask;
private final FastList<Statement> openStatements; private final FastList<Statement> openStatements;
private int dirtyBits; private int dirtyBits;
private long lastAccess; private long lastAccess;
private boolean isCommitStateDirty; private boolean isCommitStateDirty;
protected boolean isAutoCommit; private boolean isReadOnly;
private boolean isAutoCommit;
private int networkTimeout; private int networkTimeout;
private int transactionIsolation; private int transactionIsolation;
private String dbcatalog; private String dbcatalog;
private boolean isReadOnly;
// static initializer // static initializer
static { static {
@ -83,12 +83,13 @@ public abstract class ProxyConnection implements Connection
SQL_ERRORS.add("JZ0C1"); // Sybase disconnect error 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.poolEntry = poolEntry;
this.delegate = connection; this.delegate = connection;
this.openStatements = openStatements; this.openStatements = openStatements;
this.leakTask = leakTask; this.leakTask = leakTask;
this.lastAccess = now; this.lastAccess = now;
this.isReadOnly = isReadOnly;
this.isAutoCommit = isAutoCommit; this.isAutoCommit = isAutoCommit;
} }
@ -227,7 +228,7 @@ public abstract class ProxyConnection implements Connection
leakTask.cancel(); leakTask.cancel();
try { try {
if (isCommitStateDirty && !isAutoCommit) { if (isCommitStateDirty && !isAutoCommit && !isReadOnly) {
delegate.rollback(); delegate.rollback();
lastAccess = clockSource.currentTime(); lastAccess = clockSource.currentTime();
LOGGER.debug("{} - Executed rollback on connection {} due to dirty commit state on close().", poolEntry.getPoolName(), delegate); 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. * Create a proxy for the specified {@link Connection} instance.
* @param openStatements * @param poolEntry
* @param connection * @param connection
* * @param openStatements
* @param connectionState the PoolBagEntry entry for this proxy * @param leakTask
* @param openStatements a leak detetection task * @param now
* @param now current timestamp in milliseconds * @param isReadOnly
* @param isAutoCommit
* @return a proxy that wraps the specified {@link Connection} * @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 // 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."); throw new IllegalStateException("You need to run the CLI build and you need target/classes in your classpath to run.");

Loading…
Cancel
Save