From 1daf44b75480abb98522bf657eacdca92f0fd8e2 Mon Sep 17 00:00:00 2001 From: Nitin Date: Thu, 8 Oct 2015 11:20:46 +0530 Subject: [PATCH 1/2] using Throwable, better for backport too --- src/main/java/com/zaxxer/hikari/pool/HikariPool.java | 2 +- src/main/java/com/zaxxer/hikari/pool/PoolBase.java | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/zaxxer/hikari/pool/HikariPool.java b/src/main/java/com/zaxxer/hikari/pool/HikariPool.java index 3f42fc33..e4592c00 100644 --- a/src/main/java/com/zaxxer/hikari/pool/HikariPool.java +++ b/src/main/java/com/zaxxer/hikari/pool/HikariPool.java @@ -528,7 +528,7 @@ public class HikariPool extends PoolBase implements HikariPoolMXBean, IBagStateL final PoolEntry poolEntry = connectionBag.borrow(connectionTimeout, TimeUnit.MILLISECONDS); if (config.getMinimumIdle() == 0) { - closeConnection(poolEntry, "Initialization validation complete, closing test connection."); + closeConnection(poolEntry, "Closing connection borrowed for validation."); } else { connectionBag.requite(poolEntry); diff --git a/src/main/java/com/zaxxer/hikari/pool/PoolBase.java b/src/main/java/com/zaxxer/hikari/pool/PoolBase.java index 09ce2dbd..1a57f56f 100644 --- a/src/main/java/com/zaxxer/hikari/pool/PoolBase.java +++ b/src/main/java/com/zaxxer/hikari/pool/PoolBase.java @@ -99,11 +99,10 @@ abstract class PoolBase void quietlyCloseConnection(final Connection connection, final String closureReason) { + if (connection == null) { + return; + } try { - if (connection == null) { - return; - } - LOGGER.debug("{} - Closing connection {}: {}", poolName, connection, closureReason); try { setNetworkTimeout(connection, TimeUnit.SECONDS.toMillis(15)); @@ -525,7 +524,7 @@ abstract class PoolBase try { dataSource.setLoginTimeout((int) TimeUnit.MILLISECONDS.toSeconds(Math.max(1000L, connectionTimeout))); } - catch (SQLException | UnsupportedOperationException e) { + catch (Throwable e) { LOGGER.warn("{} - Unable to set DataSource login timeout", poolName, e); } } From 0218ed14b5d9a5d717ea77c8d39b1b7c524104ae Mon Sep 17 00:00:00 2001 From: Nitin Date: Thu, 8 Oct 2015 14:31:08 +0530 Subject: [PATCH 2/2] format --- src/main/java/com/zaxxer/hikari/pool/PoolBase.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/zaxxer/hikari/pool/PoolBase.java b/src/main/java/com/zaxxer/hikari/pool/PoolBase.java index 1a57f56f..291da338 100644 --- a/src/main/java/com/zaxxer/hikari/pool/PoolBase.java +++ b/src/main/java/com/zaxxer/hikari/pool/PoolBase.java @@ -102,6 +102,7 @@ abstract class PoolBase if (connection == null) { return; } + try { LOGGER.debug("{} - Closing connection {}: {}", poolName, connection, closureReason); try {