minor cleanup

pull/445/head
Brett Wooldridge 10 years ago
parent 3c3a14bd3f
commit 03aad4ea35

@ -1,6 +1,11 @@
package com.zaxxer.hikari.pool; package com.zaxxer.hikari.pool;
import static com.zaxxer.hikari.util.UtilityElf.createInstance; import static com.zaxxer.hikari.util.UtilityElf.createInstance;
import static com.zaxxer.hikari.pool.ProxyConnection.DIRTY_BIT_CATALOG;
import static com.zaxxer.hikari.pool.ProxyConnection.DIRTY_BIT_READONLY;
import static com.zaxxer.hikari.pool.ProxyConnection.DIRTY_BIT_ISOLATION;
import static com.zaxxer.hikari.pool.ProxyConnection.DIRTY_BIT_AUTOCOMMIT;
import static com.zaxxer.hikari.pool.ProxyConnection.DIRTY_BIT_NETTIMEOUT;
import java.lang.management.ManagementFactory; import java.lang.management.ManagementFactory;
import java.sql.Connection; import java.sql.Connection;
@ -170,32 +175,32 @@ abstract class PoolBase
{ {
int resetBits = 0; int resetBits = 0;
if ((dirtyBits & 0b00001) != 0 && proxyConnection.getReadOnlyState() != isReadOnly) { if ((dirtyBits & DIRTY_BIT_READONLY) != 0 && proxyConnection.getReadOnlyState() != isReadOnly) {
connection.setReadOnly(isReadOnly); connection.setReadOnly(isReadOnly);
resetBits |= 0b00001; resetBits |= DIRTY_BIT_READONLY;
} }
if ((dirtyBits & 0b00010) != 0 && proxyConnection.getAutoCommitState() != isAutoCommit) { if ((dirtyBits & DIRTY_BIT_AUTOCOMMIT) != 0 && proxyConnection.getAutoCommitState() != isAutoCommit) {
connection.setAutoCommit(isAutoCommit); connection.setAutoCommit(isAutoCommit);
resetBits |= 0b00010; resetBits |= DIRTY_BIT_AUTOCOMMIT;
} }
if ((dirtyBits & 0b00100) != 0 && proxyConnection.getTransactionIsolationState() != transactionIsolation) { if ((dirtyBits & DIRTY_BIT_ISOLATION) != 0 && proxyConnection.getTransactionIsolationState() != transactionIsolation) {
connection.setTransactionIsolation(transactionIsolation); connection.setTransactionIsolation(transactionIsolation);
resetBits |= 0b00100; resetBits |= DIRTY_BIT_ISOLATION;
} }
if ((dirtyBits & 0b01000) != 0) { if ((dirtyBits & DIRTY_BIT_CATALOG) != 0) {
final String currentCatalog = proxyConnection.getCatalogState(); final String currentCatalog = proxyConnection.getCatalogState();
if ((currentCatalog != null && !currentCatalog.equals(catalog)) || (currentCatalog == null && catalog != null)) { if ((currentCatalog != null && !currentCatalog.equals(catalog)) || (currentCatalog == null && catalog != null)) {
connection.setCatalog(catalog); connection.setCatalog(catalog);
resetBits |= 0b01000; resetBits |= DIRTY_BIT_CATALOG;
} }
} }
if ((dirtyBits & 0b10000) != 0 && proxyConnection.getNetworkTimeoutState() != networkTimeout) { if ((dirtyBits & DIRTY_BIT_NETTIMEOUT) != 0 && proxyConnection.getNetworkTimeoutState() != networkTimeout) {
setNetworkTimeout(connection, networkTimeout); setNetworkTimeout(connection, networkTimeout);
resetBits |= 0b10000; resetBits |= DIRTY_BIT_NETTIMEOUT;
} }
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {

@ -43,6 +43,12 @@ import com.zaxxer.hikari.util.FastList;
*/ */
public abstract class ProxyConnection implements Connection public abstract class ProxyConnection implements Connection
{ {
static final int DIRTY_BIT_READONLY = 0b00001;
static final int DIRTY_BIT_AUTOCOMMIT = 0b00010;
static final int DIRTY_BIT_ISOLATION = 0b00100;
static final int DIRTY_BIT_CATALOG = 0b01000;
static final int DIRTY_BIT_NETTIMEOUT = 0b10000;
private static final Logger LOGGER; private static final Logger LOGGER;
private static final Set<String> SQL_ERRORS; private static final Set<String> SQL_ERRORS;
private static final ClockSource clockSource; private static final ClockSource clockSource;
@ -371,7 +377,7 @@ public abstract class ProxyConnection implements Connection
{ {
delegate.setAutoCommit(autoCommit); delegate.setAutoCommit(autoCommit);
isAutoCommit = autoCommit; isAutoCommit = autoCommit;
dirtyBits |= 0b00010; dirtyBits |= DIRTY_BIT_AUTOCOMMIT;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@ -380,7 +386,7 @@ public abstract class ProxyConnection implements Connection
{ {
delegate.setReadOnly(readOnly); delegate.setReadOnly(readOnly);
isReadOnly = readOnly; isReadOnly = readOnly;
dirtyBits |= 0b00001; dirtyBits |= DIRTY_BIT_READONLY;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@ -389,7 +395,7 @@ public abstract class ProxyConnection implements Connection
{ {
delegate.setTransactionIsolation(level); delegate.setTransactionIsolation(level);
transactionIsolation = level; transactionIsolation = level;
dirtyBits |= 0b00100; dirtyBits |= DIRTY_BIT_ISOLATION;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@ -398,7 +404,7 @@ public abstract class ProxyConnection implements Connection
{ {
delegate.setCatalog(catalog); delegate.setCatalog(catalog);
dbcatalog = catalog; dbcatalog = catalog;
dirtyBits |= 0b01000; dirtyBits |= DIRTY_BIT_CATALOG;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@ -407,7 +413,7 @@ public abstract class ProxyConnection implements Connection
{ {
delegate.setNetworkTimeout(executor, milliseconds); delegate.setNetworkTimeout(executor, milliseconds);
networkTimeout = milliseconds; networkTimeout = milliseconds;
dirtyBits |= 0b10000; dirtyBits |= DIRTY_BIT_NETTIMEOUT;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */

Loading…
Cancel
Save