removed isClosed(), why trip to check when close() is no-op if already

closed, moreover isClosed() was not guarded by network timeout. mostly
call to close would be once anyway.
pull/438/head
Nitin 10 years ago
parent 6137805ab3
commit c37a6cb20a

@ -173,8 +173,7 @@ public class HikariPool extends PoolBase implements HikariPoolMXBean, IBagStateL
metricsTracker.recordBorrowStats(poolEntry, startTime); metricsTracker.recordBorrowStats(poolEntry, startTime);
return poolEntry.createProxyConnection(leakTask.start(poolEntry), now); return poolEntry.createProxyConnection(leakTask.start(poolEntry), now);
} }
} } while (timeout > 0L);
while (timeout > 0L);
} }
catch (InterruptedException e) { catch (InterruptedException e) {
throw new SQLException(poolName + " - Interrupted during connection acquisition", e); throw new SQLException(poolName + " - Interrupted during connection acquisition", e);
@ -227,8 +226,7 @@ public class HikariPool extends PoolBase implements HikariPoolMXBean, IBagStateL
do { do {
softEvictConnections(); softEvictConnections();
abortActiveConnections(assassinExecutor); abortActiveConnections(assassinExecutor);
} } while (getTotalConnections() > 0 && clockSource.elapsedMillis(start) < TimeUnit.SECONDS.toMillis(5));
while (getTotalConnections() > 0 && clockSource.elapsedMillis(start) < TimeUnit.SECONDS.toMillis(5));
} finally { } finally {
assassinExecutor.shutdown(); assassinExecutor.shutdown();
assassinExecutor.awaitTermination(5L, TimeUnit.SECONDS); assassinExecutor.awaitTermination(5L, TimeUnit.SECONDS);

@ -95,7 +95,7 @@ abstract class PoolBase
void quietlyCloseConnection(final Connection connection, final String closureReason) void quietlyCloseConnection(final Connection connection, final String closureReason)
{ {
try { try {
if (connection == null || connection.isClosed()) { if (connection == null) {
return; return;
} }
@ -128,10 +128,10 @@ abstract class PoolBase
if (isNetworkTimeoutSupported != TRUE) { if (isNetworkTimeoutSupported != TRUE) {
setQueryTimeout(statement, (int) TimeUnit.MILLISECONDS.toSeconds(validationTimeout)); setQueryTimeout(statement, (int) TimeUnit.MILLISECONDS.toSeconds(validationTimeout));
} }
statement.execute(config.getConnectionTestQuery()); statement.execute(config.getConnectionTestQuery());
} }
if (isIsolateInternalQueries && !isReadOnly && !isAutoCommit) { if (isIsolateInternalQueries && !isReadOnly && !isAutoCommit) {
connection.rollback(); connection.rollback();
} }
@ -461,6 +461,7 @@ abstract class PoolBase
if (sql != null) { if (sql != null) {
try (Statement statement = connection.createStatement()) { try (Statement statement = connection.createStatement()) {
//con created few ms before, set query timeout is omitted
statement.execute(sql); statement.execute(sql);
if (!isReadOnly) { if (!isReadOnly) {

Loading…
Cancel
Save