Closes #989 Merged the parts I agree with.

pull/991/head
Brett Wooldridge 7 years ago
parent e3ed1350d7
commit 6735fcfe3a

@ -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);
}

@ -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());

Loading…
Cancel
Save