Fix issue with improper initialization of lastAccessTime.

pull/158/head
Brett Wooldridge 11 years ago
parent a3c7b5574f
commit efaf86156c

@ -394,20 +394,16 @@ public final class HikariPool implements HikariPoolMBean, IBagStateListener
*/
private void closeConnection(final PoolBagEntry bagEntry)
{
try {
int tc = totalConnections.decrementAndGet();
if (tc < 0) {
LOGGER.warn("Internal accounting inconsistency, totalConnections={}", tc, new Exception());
}
closeConnectionExecutor.submit(new Runnable() {
public void run() {
quietlyCloseConnection(bagEntry.connection);
}
});
}
finally {
connectionBag.remove(bagEntry);
int tc = totalConnections.decrementAndGet();
connectionBag.remove(bagEntry);
if (tc < 0) {
LOGGER.warn("Internal accounting inconsistency, totalConnections={}", tc, new Exception());
}
closeConnectionExecutor.submit(new Runnable() {
public void run() {
quietlyCloseConnection(bagEntry.connection);
}
});
}
/**

@ -35,7 +35,18 @@ public final class PoolBagEntry extends BagEntry
PoolBagEntry(final Connection connection, long maxLifetime) {
this.connection = connection;
expirationTime = (maxLifetime > 0 ? System.currentTimeMillis() + maxLifetime : Long.MAX_VALUE);
lastAccess = expirationTime;
lastAccess = System.currentTimeMillis();
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("Connection: ").append(connection).append('\n');
sb.append("Expiration: ").append(expirationTime).append('\n');
sb.append("Last access: ").append(lastAccess).append('\n');
sb.append("Last open: ").append(lastOpenTime);
return sb.toString();
}
}

@ -385,16 +385,12 @@ public final class HikariPool implements HikariPoolMBean, IBagStateListener
*/
private void closeConnection(final PoolBagEntry bagEntry)
{
try {
int tc = totalConnections.decrementAndGet();
if (tc < 0) {
LOGGER.warn("Internal accounting inconsistency, totalConnections={}", tc, new Exception());
}
closeConnectionExecutor.submit(() -> { quietlyCloseConnection(bagEntry.connection); });
}
finally {
connectionBag.remove(bagEntry);
int tc = totalConnections.decrementAndGet();
connectionBag.remove(bagEntry);
if (tc < 0) {
LOGGER.warn("Internal accounting inconsistency, totalConnections={}", tc, new Exception());
}
closeConnectionExecutor.submit(() -> { quietlyCloseConnection(bagEntry.connection); });
}
/**
@ -469,7 +465,7 @@ public final class HikariPool implements HikariPoolMBean, IBagStateListener
}
}
catch (SQLException e) {
LOGGER.warn("Exception during keep alive check, that means the connection must be dead.", e);
LOGGER.warn("Exception during keep alive check, that means the connection (" + connection + ") must be dead.", e);
return false;
}
}

@ -35,7 +35,18 @@ public final class PoolBagEntry extends BagEntry
PoolBagEntry(final Connection connection, long maxLifetime) {
this.connection = connection;
expirationTime = (maxLifetime > 0 ? System.currentTimeMillis() + maxLifetime : Long.MAX_VALUE);
lastAccess = expirationTime;
lastAccess = System.currentTimeMillis();
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("Connection: ").append(connection).append('\n');
sb.append("Expiration: ").append(expirationTime).append('\n');
sb.append("Last access: ").append(lastAccess).append('\n');
sb.append("Last open: ").append(lastOpenTime);
return sb.toString();
}
}

Loading…
Cancel
Save