diff --git a/src/main/java/com/zaxxer/hikari/pool/HikariPool.java b/src/main/java/com/zaxxer/hikari/pool/HikariPool.java index a7c65b25..a1a12349 100755 --- a/src/main/java/com/zaxxer/hikari/pool/HikariPool.java +++ b/src/main/java/com/zaxxer/hikari/pool/HikariPool.java @@ -160,11 +160,11 @@ public final class HikariPool extends PoolBase implements HikariPoolMXBean, IBag { suspendResumeLock.acquire(); final long startTime = currentTime(); - PoolEntry poolEntry = null; + try { long timeout = hardTimeout; do { - poolEntry = connectionBag.borrow(timeout, MILLISECONDS); + PoolEntry poolEntry = connectionBag.borrow(timeout, MILLISECONDS); if (poolEntry == null) { break; // We timed out... break and throw exception } @@ -183,9 +183,6 @@ public final class HikariPool extends PoolBase implements HikariPoolMXBean, IBag metricsTracker.recordBorrowTimeoutStats(startTime); } catch (InterruptedException e) { - if (poolEntry != null) { - poolEntry.recycle(startTime); - } Thread.currentThread().interrupt(); throw new SQLException(poolName + " - Interrupted during connection acquisition", e); } diff --git a/src/main/java/com/zaxxer/hikari/pool/PoolBase.java b/src/main/java/com/zaxxer/hikari/pool/PoolBase.java index 9063d817..655322e7 100755 --- a/src/main/java/com/zaxxer/hikari/pool/PoolBase.java +++ b/src/main/java/com/zaxxer/hikari/pool/PoolBase.java @@ -30,7 +30,6 @@ import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; import javax.management.MBeanServer; @@ -155,15 +154,15 @@ abstract class PoolBase try { setNetworkTimeout(connection, validationTimeout); - final long validationSeconds = (int) Math.max(1000L, validationTimeout) / 1000; + final int validationSeconds = (int) Math.max(1000L, validationTimeout) / 1000; if (isUseJdbc4Validation) { - return connection.isValid((int) validationSeconds); + return connection.isValid(validationSeconds); } try (Statement statement = connection.createStatement()) { if (isNetworkTimeoutSupported != TRUE) { - setQueryTimeout(statement, (int) validationSeconds); + setQueryTimeout(statement, validationSeconds); } statement.execute(config.getConnectionTestQuery());