From 2c9dd89abae7fa1c021350302409a6a2d3d94eaa Mon Sep 17 00:00:00 2001 From: Brett Wooldridge Date: Tue, 25 Mar 2025 02:25:13 +0900 Subject: [PATCH 01/22] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 55fa92c85..0278f89f6 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ _**Java 11+** maven artifact:_ com.zaxxer HikariCP - 6.2.1 + 6.3.0 ``` _Java 8 maven artifact (*deprecated*):_ From ddee141c19b4b9bcb2931b44fc37f1b4ccd1c678 Mon Sep 17 00:00:00 2001 From: Brett Wooldridge Date: Tue, 25 Mar 2025 02:54:36 +0900 Subject: [PATCH 02/22] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0278f89f6..969efeb87 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ Fast, simple, reliable. HikariCP is a "zero-overhead" production ready JDBC con ### Artifacts -_**Java 11+** maven artifact:_ +_**Java 11 or greater** maven artifact:_ ```xml com.zaxxer From 207442795afa3ac5612138c1208f06ee5790cf21 Mon Sep 17 00:00:00 2001 From: Brett Wooldridge Date: Sun, 6 Apr 2025 03:35:01 +0900 Subject: [PATCH 03/22] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 969efeb87..9f68aeaf2 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Fast, simple, reliable. HikariCP is a "zero-overhead" production ready JDBC con ---------------------------------------------------- > [!IMPORTANT] -> In order to avoid a rare condition where the pool goes to zero and does not recover it is necessary to configure *TCP keepalive*. Some JDBC drivers support this via properties, for example ``tcpKeepAlive=true`` on PostgreSQL, but in any case it can also be configured at the OS-level. See [Setting OS TCP Keepalive](https://github.com/brettwooldridge/HikariCP/wiki/Setting-OS-TCP-Keepalive) and/or [TCP keepalive for a better PostgreSQL experience](https://www.cybertec-postgresql.com/en/tcp-keepalive-for-a-better-postgresql-experience/#setting-tcp-keepalive-parameters-on-the-operating-system). +> In order to avoid a rare condition where the pool goes to zero and does not recover it is necessary to configure *TCP keepalive*. Some JDBC drivers support this via properties, for example ``tcpKeepAlive=true`` on PostgreSQL, but in any case it can also be configured at the OS-level. See [Setting OS TCP Keepalive](https://github.com/brettwooldridge/HikariCP/wiki/Setting-Driver-or-OS-TCP-Keepalive) and/or [TCP keepalive for a better PostgreSQL experience](https://www.cybertec-postgresql.com/en/tcp-keepalive-for-a-better-postgresql-experience/#setting-tcp-keepalive-parameters-on-the-operating-system). ---------------------------------------------------- From d8a4706bcbdc222e96a1e328e205ca2eab37e69a Mon Sep 17 00:00:00 2001 From: Brett Wooldridge Date: Sun, 13 Apr 2025 02:09:28 +0900 Subject: [PATCH 04/22] fixes#2307 remove hardcoded timout, use validationTimeout --- src/main/java/com/zaxxer/hikari/pool/PoolBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/zaxxer/hikari/pool/PoolBase.java b/src/main/java/com/zaxxer/hikari/pool/PoolBase.java index 1921db1b0..2e8eae089 100644 --- a/src/main/java/com/zaxxer/hikari/pool/PoolBase.java +++ b/src/main/java/com/zaxxer/hikari/pool/PoolBase.java @@ -475,7 +475,7 @@ private void checkValidationSupport(final Connection connection) throws SQLExcep { try { if (isUseJdbc4Validation) { - connection.isValid(1); + connection.isValid(Math.max(1, (int) MILLISECONDS.toSeconds(validationTimeout))); } else { executeSql(connection, config.getConnectionTestQuery(), false); From 491c9fb75ba88f47085c4ac29fc60fa6ba30a638 Mon Sep 17 00:00:00 2001 From: Yanming Zhou Date: Sun, 13 Apr 2025 01:25:09 +0800 Subject: [PATCH 05/22] Keep properties keys and values as it is (#2305) Fix GH-2304 Fix GH-2286 --- .../com/zaxxer/hikari/util/DriverDataSource.java | 4 +--- .../zaxxer/hikari/util/DriverDataSourceTest.java | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/zaxxer/hikari/util/DriverDataSource.java b/src/main/java/com/zaxxer/hikari/util/DriverDataSource.java index fe7f908c1..bb24af109 100644 --- a/src/main/java/com/zaxxer/hikari/util/DriverDataSource.java +++ b/src/main/java/com/zaxxer/hikari/util/DriverDataSource.java @@ -45,9 +45,7 @@ public DriverDataSource(String jdbcUrl, String driverClassName, Properties prope this.jdbcUrl = jdbcUrl; this.driverProperties = new Properties(); - for (var entry : properties.entrySet()) { - driverProperties.setProperty(entry.getKey().toString(), entry.getValue().toString()); - } + driverProperties.putAll(properties); if (username != null) { driverProperties.put(USER, driverProperties.getProperty(USER, username)); diff --git a/src/test/java/com/zaxxer/hikari/util/DriverDataSourceTest.java b/src/test/java/com/zaxxer/hikari/util/DriverDataSourceTest.java index c0bd5b381..26e4a3df6 100644 --- a/src/test/java/com/zaxxer/hikari/util/DriverDataSourceTest.java +++ b/src/test/java/com/zaxxer/hikari/util/DriverDataSourceTest.java @@ -18,6 +18,8 @@ import org.junit.Test; +import java.lang.reflect.Field; +import java.time.Duration; import java.util.Arrays; import java.util.List; import java.util.Properties; @@ -26,6 +28,18 @@ public class DriverDataSourceTest { + @Test + public void testDriverProperties() throws Exception { + Properties properties = new Properties(); + Duration timeout = Duration.ofSeconds(60); + properties.put("timeout", timeout); + var driverDataSource = new DriverDataSource("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", null, properties, "", ""); + Field field = DriverDataSource.class.getDeclaredField("driverProperties"); + field.setAccessible(true); + Properties driverProperties = (Properties) field.get(driverDataSource); + assertEquals(timeout, driverProperties.get("timeout")); + } + @Test public void testJdbcUrlLogging() { List urls = Arrays.asList( From 4f732c301556424bc4b80a8ef363fc5bb0c387ca Mon Sep 17 00:00:00 2001 From: Brett Wooldridge Date: Mon, 26 May 2025 20:27:26 +0900 Subject: [PATCH 06/22] Remove pom configuration added when trying to generate a multi-version jar back in the day. It was causing .class files to be included in the sources jar. (#2315) --- pom.xml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pom.xml b/pom.xml index 18fa06421..04982958d 100644 --- a/pom.xml +++ b/pom.xml @@ -287,12 +287,6 @@ - - - target/classes - - - From 47f9adc0812180b5871ee623235db8071db60abf Mon Sep 17 00:00:00 2001 From: Brett Wooldridge Date: Tue, 27 May 2025 11:31:34 +0900 Subject: [PATCH 07/22] update CHANGES file --- CHANGES | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGES b/CHANGES index 7d84bcde6..b83d4d807 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,15 @@ HikariCP Changes +Changes in 6.3.1 + + * fixed #2315 source jar contains also binary .class files and missing some .java files + + * fixed #2307 remove improper hardcoded timout, use validationTimeout + + * fixed #2305 keep properties key and values as is rather than forcing stringification. Also fixes #2286 and #2304 + + * upgraded various maven plugin dependencies to latest versions + Changes in 6.3.0 * increase keepaliveTime variance from 10% to 20% From 4ef1ec96ebf3fcef3760e4565201bb2fea3a3189 Mon Sep 17 00:00:00 2001 From: Brett Wooldridge Date: Tue, 27 May 2025 11:31:57 +0900 Subject: [PATCH 08/22] update various maven plugin dependencies to latest --- pom.xml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index 04982958d..0a0c33752 100644 --- a/pom.xml +++ b/pom.xml @@ -292,13 +292,13 @@ org.apache.maven.plugins maven-clean-plugin - 3.2.0 + 3.4.1 org.apache.maven.plugins maven-compiler-plugin - 3.10.1 + 3.14.0 11 11 @@ -309,19 +309,19 @@ org.apache.maven.plugins maven-deploy-plugin - 2.8.2 + 3.1.4 org.apache.maven.plugins maven-gpg-plugin - 3.0.1 + 3.2.7 org.apache.maven.plugins maven-release-plugin - 2.5.3 + 3.1.1 @@ -333,7 +333,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.0.0-M8 + 3.5.3 ${surefireArgLine} ${sureFireOptions11} @@ -344,7 +344,7 @@ org.apache.maven.plugins maven-source-plugin - 3.0.1 + 3.3.1 @@ -363,7 +363,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.6.0 + 3.11.2 public @@ -389,7 +389,7 @@ org.apache.maven.plugins maven-enforcer-plugin - 3.4.1 + 3.5.0 enforce-maven @@ -409,7 +409,7 @@ maven-dependency-plugin - 2.8 + 3.8.1 generate-sources @@ -427,7 +427,7 @@ org.codehaus.mojo exec-maven-plugin - 1.6.0 + 3.5.0 true @@ -502,7 +502,7 @@ org.jacoco jacoco-maven-plugin - 0.8.8 + 0.8.13 @@ -543,7 +543,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.0.0-M3 + 3.5.3 From c78e3a3b27cc31018f2990265139c2b83f8c4003 Mon Sep 17 00:00:00 2001 From: Brett Wooldridge Date: Tue, 27 May 2025 23:43:01 +0900 Subject: [PATCH 09/22] migrate from ossrh to maven central publishing --- pom.xml | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/pom.xml b/pom.xml index 0a0c33752..5c156cd5b 100644 --- a/pom.xml +++ b/pom.xml @@ -73,13 +73,6 @@ HEAD - - - ossrh - https://oss.sonatype.org/content/repositories/snapshots - - - https://github.com/brettwooldridge/HikariCP/issues @@ -692,17 +685,14 @@ - - org.sonatype.plugins - nexus-staging-maven-plugin + org.sonatype.central + central-publishing-maven-plugin + 0.7.0 true - ${autoReleaseStagedArtifacts} - https://oss.sonatype.org/ - ossrh + central + false From 52bdeaf876267c14f7fc127f94cd1d130b76c309 Mon Sep 17 00:00:00 2001 From: Brett Wooldridge Date: Wed, 28 May 2025 00:21:19 +0900 Subject: [PATCH 10/22] cleanup publishing phase --- pom.xml | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/pom.xml b/pom.xml index 5c156cd5b..5850ec43e 100644 --- a/pom.xml +++ b/pom.xml @@ -24,11 +24,6 @@ - - true - 0.45.0 5.1.1 7.0.5 @@ -311,18 +306,6 @@ 3.2.7 - - org.apache.maven.plugins - maven-release-plugin - 3.1.1 - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.12 - - org.apache.maven.plugins maven-surefire-plugin @@ -641,6 +624,16 @@ + + + org.apache.maven.plugins + maven-release-plugin + ${maven.release.version} + + clean verify + + + org.apache.maven.plugins maven-source-plugin @@ -648,6 +641,7 @@ attach-sources + verify jar-no-fork @@ -662,6 +656,7 @@ attach-javadocs + verify jar @@ -669,8 +664,6 @@ - org.apache.maven.plugins maven-gpg-plugin @@ -694,6 +687,15 @@ central false + + + publish + deploy + + publish + + + From 71403729f7bb8568bc81325da9ebaec5cf4ac3c8 Mon Sep 17 00:00:00 2001 From: Brett Wooldridge Date: Wed, 28 May 2025 00:27:31 +0900 Subject: [PATCH 11/22] add publish.sh script for convenience --- publish.sh | 4 ++++ 1 file changed, 4 insertions(+) create mode 100755 publish.sh diff --git a/publish.sh b/publish.sh new file mode 100755 index 000000000..45a929e93 --- /dev/null +++ b/publish.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +mvn release:prepare -Prelease && mvn deploy -DperformRelease=true + From 07a3efb816732f667ade08263f4b78554d681c26 Mon Sep 17 00:00:00 2001 From: Brett Wooldridge Date: Wed, 28 May 2025 00:54:46 +0900 Subject: [PATCH 12/22] remove redundant plugin definitions from the release profile --- pom.xml | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/pom.xml b/pom.xml index 5850ec43e..e9bfe0fd9 100644 --- a/pom.xml +++ b/pom.xml @@ -634,36 +634,6 @@ - - org.apache.maven.plugins - maven-source-plugin - 3.3.0 - - - attach-sources - verify - - jar-no-fork - - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.6.0 - - - attach-javadocs - verify - - jar - - - - - org.apache.maven.plugins maven-gpg-plugin From f0ffb11510a30c312b74d9763b2b8bf804244cf3 Mon Sep 17 00:00:00 2001 From: Brett Wooldridge Date: Wed, 28 May 2025 01:21:51 +0900 Subject: [PATCH 13/22] minor cleanup --- pom.xml | 4 +--- publish.sh | 3 +-- src/test/resources/log4j2-test.xml | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index e9bfe0fd9..20b681ee3 100644 --- a/pom.xml +++ b/pom.xml @@ -342,9 +342,7 @@ 3.11.2 public - - com.zaxxer.hikari.hibernate:com.zaxxer.hikari.metrics.*:com.zaxxer.hikari.pool:com.zaxxer.hikari.util - + com.zaxxer.hikari.hibernate:com.zaxxer.hikari.metrics.*:com.zaxxer.hikari.pool:com.zaxxer.hikari.util true 1024m diff --git a/publish.sh b/publish.sh index 45a929e93..d71be3d07 100755 --- a/publish.sh +++ b/publish.sh @@ -1,4 +1,3 @@ #!/bin/bash -mvn release:prepare -Prelease && mvn deploy -DperformRelease=true - +mvn release:prepare -Prelease && mvn deploy -DperformRelease=true -DskipTests -Dmaven.test.skip=true diff --git a/src/test/resources/log4j2-test.xml b/src/test/resources/log4j2-test.xml index 85d33b927..f287ff1a3 100644 --- a/src/test/resources/log4j2-test.xml +++ b/src/test/resources/log4j2-test.xml @@ -1,7 +1,7 @@ - + From 00e67c7f861470363ff722708f21ced1b72fd718 Mon Sep 17 00:00:00 2001 From: Brett Wooldridge Date: Wed, 28 May 2025 01:54:10 +0900 Subject: [PATCH 14/22] remove conflicting plugin --- pom.xml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pom.xml b/pom.xml index 20b681ee3..ba211473c 100644 --- a/pom.xml +++ b/pom.xml @@ -294,12 +294,6 @@ - - org.apache.maven.plugins - maven-deploy-plugin - 3.1.4 - - org.apache.maven.plugins maven-gpg-plugin From bcf82649be0eddd1dca7797149056cca9e21f7f7 Mon Sep 17 00:00:00 2001 From: Brett Wooldridge Date: Wed, 28 May 2025 02:05:43 +0900 Subject: [PATCH 15/22] attempt to fix javadoc generation issue --- pom.xml | 2 +- publish.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index ba211473c..9f2d99a8a 100644 --- a/pom.xml +++ b/pom.xml @@ -333,7 +333,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.11.2 + 3.6.0 public com.zaxxer.hikari.hibernate:com.zaxxer.hikari.metrics.*:com.zaxxer.hikari.pool:com.zaxxer.hikari.util diff --git a/publish.sh b/publish.sh index d71be3d07..da47e3a48 100755 --- a/publish.sh +++ b/publish.sh @@ -1,3 +1,3 @@ #!/bin/bash -mvn release:prepare -Prelease && mvn deploy -DperformRelease=true -DskipTests -Dmaven.test.skip=true +mvn clean && mvn package -DskipTests -Dmaven.test.skip=true && mvn release:prepare -Prelease && mvn deploy -DperformRelease=true -DskipTests -Dmaven.test.skip=true From c701b1beadd66ddad066aa2b8549538ee7ee1278 Mon Sep 17 00:00:00 2001 From: Brett Wooldridge Date: Thu, 29 May 2025 01:12:38 +0900 Subject: [PATCH 16/22] revert plugin versions. maven-javadoc-plugin is broken wrt modules. --- pom.xml | 95 +++++++++++++++++++++++++++------------------------------ 1 file changed, 45 insertions(+), 50 deletions(-) diff --git a/pom.xml b/pom.xml index 9f2d99a8a..0680f767d 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ 5.4.24.Final 3.29.2-GA 0.11.4.1 - 3.0.1 + 2.5.3 3.2.5 5.0.0-rc17 1.5.10 @@ -280,13 +280,13 @@ org.apache.maven.plugins maven-clean-plugin - 3.4.1 + 3.2.0 org.apache.maven.plugins maven-compiler-plugin - 3.14.0 + 3.10.1 11 11 @@ -294,12 +294,6 @@ - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.7 - - org.apache.maven.plugins maven-surefire-plugin @@ -310,46 +304,6 @@ ${sureFireForks11} - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - true - - - - attach-sources - - jar-no-fork - - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.6.0 - - public - com.zaxxer.hikari.hibernate:com.zaxxer.hikari.metrics.*:com.zaxxer.hikari.pool:com.zaxxer.hikari.util - true - 1024m - - - - bundle-sources - package - - jar - - - - @@ -395,7 +349,7 @@ org.codehaus.mojo exec-maven-plugin - 3.5.0 + 1.6.0 true @@ -626,9 +580,50 @@ + + org.apache.maven.plugins + maven-source-plugin + 3.0.1 + + + true + + + + attach-sources + + jar-no-fork + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.6.0 + + public + com.zaxxer.hikari.hibernate:com.zaxxer.hikari.metrics.*:com.zaxxer.hikari.pool:com.zaxxer.hikari.util + true + 1024m + + + + bundle-sources + package + + jar + + + + + org.apache.maven.plugins maven-gpg-plugin + 3.0.1 sign-artifacts From dcb5185c3ce1459c7ddaa1893d17b6bd41e57453 Mon Sep 17 00:00:00 2001 From: Brett Wooldridge Date: Thu, 29 May 2025 01:34:37 +0900 Subject: [PATCH 17/22] add sourcepath --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 0680f767d..2a54cb7c1 100644 --- a/pom.xml +++ b/pom.xml @@ -605,6 +605,7 @@ 3.6.0 public + src/main/java com.zaxxer.hikari.hibernate:com.zaxxer.hikari.metrics.*:com.zaxxer.hikari.pool:com.zaxxer.hikari.util true 1024m From afdefdfeca9052a10a31ece67b056e00ed30f213 Mon Sep 17 00:00:00 2001 From: Brett Wooldridge Date: Thu, 29 May 2025 02:04:08 +0900 Subject: [PATCH 18/22] add sourcepath --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2a54cb7c1..a3ed1774d 100644 --- a/pom.xml +++ b/pom.xml @@ -605,7 +605,7 @@ 3.6.0 public - src/main/java + ${project.build.sourceDirectory} com.zaxxer.hikari.hibernate:com.zaxxer.hikari.metrics.*:com.zaxxer.hikari.pool:com.zaxxer.hikari.util true 1024m From 44ce7c05edf53136f5212f0569e4a0ed5ad4dbda Mon Sep 17 00:00:00 2001 From: Brett Wooldridge Date: Thu, 29 May 2025 02:20:22 +0900 Subject: [PATCH 19/22] suppress errors --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index a3ed1774d..df9cb89d4 100644 --- a/pom.xml +++ b/pom.xml @@ -605,6 +605,7 @@ 3.6.0 public + false ${project.build.sourceDirectory} com.zaxxer.hikari.hibernate:com.zaxxer.hikari.metrics.*:com.zaxxer.hikari.pool:com.zaxxer.hikari.util true From b5453122a683b23e5b9df490868737430b1c0d71 Mon Sep 17 00:00:00 2001 From: Brett Wooldridge Date: Thu, 29 May 2025 02:26:20 +0900 Subject: [PATCH 20/22] [maven-release-plugin] prepare release HikariCP-6.3.1 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index df9cb89d4..cc64065fa 100644 --- a/pom.xml +++ b/pom.xml @@ -49,7 +49,7 @@ com.zaxxer HikariCP - 6.3.1-SNAPSHOT + 6.3.1 bundle HikariCP @@ -65,7 +65,7 @@ scm:git:https://github.com/brettwooldridge/HikariCP.git scm:git:https://github.com/brettwooldridge/HikariCP.git https://github.com/brettwooldridge/HikariCP - HEAD + HikariCP-6.3.1 From b2c8bb057532a657b1966232284ab35bb94d703f Mon Sep 17 00:00:00 2001 From: Brett Wooldridge Date: Thu, 29 May 2025 02:26:24 +0900 Subject: [PATCH 21/22] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index cc64065fa..750eb27e9 100644 --- a/pom.xml +++ b/pom.xml @@ -49,7 +49,7 @@ com.zaxxer HikariCP - 6.3.1 + 6.3.2-SNAPSHOT bundle HikariCP @@ -65,7 +65,7 @@ scm:git:https://github.com/brettwooldridge/HikariCP.git scm:git:https://github.com/brettwooldridge/HikariCP.git https://github.com/brettwooldridge/HikariCP - HikariCP-6.3.1 + HEAD From 2b662413b12fc5b79b78f85991bb173a73ab0925 Mon Sep 17 00:00:00 2001 From: yx91490 Date: Sun, 8 Jun 2025 14:53:22 +0800 Subject: [PATCH 22/22] Fix ContextClassLoader load priority problem in DriverDataSource --- .../zaxxer/hikari/util/DriverDataSource.java | 59 ++++++++----------- 1 file changed, 24 insertions(+), 35 deletions(-) diff --git a/src/main/java/com/zaxxer/hikari/util/DriverDataSource.java b/src/main/java/com/zaxxer/hikari/util/DriverDataSource.java index bb24af109..4d9e3d5d9 100644 --- a/src/main/java/com/zaxxer/hikari/util/DriverDataSource.java +++ b/src/main/java/com/zaxxer/hikari/util/DriverDataSource.java @@ -55,45 +55,34 @@ public DriverDataSource(String jdbcUrl, String driverClassName, Properties prope } if (driverClassName != null) { - var drivers = DriverManager.getDrivers(); - while (drivers.hasMoreElements()) { - var d = drivers.nextElement(); - if (d.getClass().getName().equals(driverClassName)) { - driver = d; - break; - } - } - - if (driver == null) { - LOGGER.warn("Registered driver with driverClassName={} was not found, trying direct instantiation.", driverClassName); - Class driverClass = null; - var threadContextClassLoader = Thread.currentThread().getContextClassLoader(); - try { - if (threadContextClassLoader != null) { - try { - driverClass = threadContextClassLoader.loadClass(driverClassName); - LOGGER.debug("Driver class {} found in Thread context class loader {}", driverClassName, threadContextClassLoader); - } - catch (ClassNotFoundException e) { - LOGGER.debug("Driver class {} not found in Thread context class loader {}, trying classloader {}", - driverClassName, threadContextClassLoader, this.getClass().getClassLoader()); - } + LOGGER.warn("Registered driver with driverClassName={} was not found, trying direct instantiation.", driverClassName); + Class driverClass = null; + var threadContextClassLoader = Thread.currentThread().getContextClassLoader(); + try { + if (threadContextClassLoader != null) { + try { + driverClass = threadContextClassLoader.loadClass(driverClassName); + LOGGER.debug("Driver class {} found in Thread context class loader {}", driverClassName, threadContextClassLoader); } - - if (driverClass == null) { - driverClass = this.getClass().getClassLoader().loadClass(driverClassName); - LOGGER.debug("Driver class {} found in the HikariConfig class classloader {}", driverClassName, this.getClass().getClassLoader()); + catch (ClassNotFoundException e) { + LOGGER.debug("Driver class {} not found in Thread context class loader {}, trying classloader {}", + driverClassName, threadContextClassLoader, this.getClass().getClassLoader()); } - } catch (ClassNotFoundException e) { - LOGGER.debug("Failed to load driver class {} from HikariConfig class classloader {}", driverClassName, this.getClass().getClassLoader()); } - if (driverClass != null) { - try { - driver = (Driver) driverClass.getDeclaredConstructor().newInstance(); - } catch (Exception e) { - LOGGER.warn("Failed to create instance of driver class {}, trying jdbcUrl resolution", driverClassName, e); - } + if (driverClass == null) { + driverClass = this.getClass().getClassLoader().loadClass(driverClassName); + LOGGER.debug("Driver class {} found in the HikariConfig class classloader {}", driverClassName, this.getClass().getClassLoader()); + } + } catch (ClassNotFoundException e) { + LOGGER.debug("Failed to load driver class {} from HikariConfig class classloader {}", driverClassName, this.getClass().getClassLoader(), e); + } + + if (driverClass != null) { + try { + driver = (Driver) driverClass.getDeclaredConstructor().newInstance(); + } catch (Exception e) { + LOGGER.warn("Failed to create instance of driver class {}, trying jdbcUrl resolution", driverClassName, e); } } }