Minor cleanup.

pull/77/head
Brett Wooldridge 11 years ago
parent 3118156f22
commit ed7234793b

@ -79,7 +79,6 @@ public final class HikariPool implements HikariPoolMBean, IBagStateListener
private volatile boolean isShutdown;
private int transactionIsolation;
private boolean isDebug;
/**
* Construct a HikariPool with the specified configuration.
@ -107,7 +106,6 @@ public final class HikariPool implements HikariPoolMBean, IBagStateListener
this.totalConnections = new AtomicInteger();
this.connectionBag = new ConcurrentBag<IHikariConnectionProxy>();
this.connectionBag.addBagStateListener(this);
this.isDebug = LOGGER.isDebugEnabled();
this.lastConnectionFailure = new AtomicReference<Throwable>();
this.catalog = configuration.getCatalog();
@ -375,7 +373,7 @@ public final class HikariPool implements HikariPoolMBean, IBagStateListener
Connection connection = null;
try
{
// Speculative increment of totalConnections with expectation of success (first time through)
// Speculative increment of totalConnections with expectation of success
if (totalConnections.incrementAndGet() > configuration.getMaximumPoolSize() || isShutdown)
{
totalConnections.decrementAndGet();
@ -400,16 +398,10 @@ public final class HikariPool implements HikariPoolMBean, IBagStateListener
// We failed, so undo speculative increment of totalConnections
totalConnections.decrementAndGet();
if (connection != null)
{
PoolUtilities.quietlyCloseConnection(connection);
}
lastConnectionFailure.set(e);
if (isDebug)
{
LOGGER.warn("Connection attempt to database {} failed: {}", configuration.getPoolName(), e.getMessage(), (isDebug ? e : null));
}
PoolUtilities.quietlyCloseConnection(connection);
LOGGER.debug("Connection attempt to database {} failed: {}", configuration.getPoolName(), e.getMessage(), e);
return false;
}
}
@ -593,7 +585,6 @@ public final class HikariPool implements HikariPoolMBean, IBagStateListener
@Override
public void run()
{
isDebug = LOGGER.isDebugEnabled();
houseKeepingTimer.purge();
logPoolState("Before pool cleanup ");

@ -27,13 +27,16 @@ public final class PoolUtilities
public static void quietlyCloseConnection(Connection connection)
{
try
{
connection.close();
}
catch (SQLException e)
if (connection != null)
{
return;
try
{
connection.close();
}
catch (SQLException e)
{
return;
}
}
}

Loading…
Cancel
Save