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% diff --git a/README.md b/README.md index 55fa92c85..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). ---------------------------------------------------- @@ -38,12 +38,12 @@ 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 HikariCP - 6.2.1 + 6.3.0 ``` _Java 8 maven artifact (*deprecated*):_ diff --git a/pom.xml b/pom.xml index 18fa06421..750eb27e9 100644 --- a/pom.xml +++ b/pom.xml @@ -24,18 +24,13 @@ - - true - 0.45.0 5.1.1 7.0.5 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 @@ -54,7 +49,7 @@ com.zaxxer HikariCP - 6.3.1-SNAPSHOT + 6.3.2-SNAPSHOT bundle HikariCP @@ -73,13 +68,6 @@ HEAD - - - ossrh - https://oss.sonatype.org/content/repositories/snapshots - - - https://github.com/brettwooldridge/HikariCP/issues @@ -287,12 +275,6 @@ - - - target/classes - - - @@ -312,82 +294,16 @@ - - org.apache.maven.plugins - maven-deploy-plugin - 2.8.2 - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.0.1 - - - - org.apache.maven.plugins - maven-release-plugin - 2.5.3 - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.12 - - org.apache.maven.plugins maven-surefire-plugin - 3.0.0-M8 + 3.5.3 ${surefireArgLine} ${sureFireOptions11} ${sureFireForks11} - - - 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 - - - - @@ -395,7 +311,7 @@ org.apache.maven.plugins maven-enforcer-plugin - 3.4.1 + 3.5.0 enforce-maven @@ -415,7 +331,7 @@ maven-dependency-plugin - 2.8 + 3.8.1 generate-sources @@ -508,7 +424,7 @@ org.jacoco jacoco-maven-plugin - 0.8.8 + 0.8.13 @@ -549,7 +465,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.0.0-M3 + 3.5.3 @@ -654,10 +570,25 @@ + + + org.apache.maven.plugins + maven-release-plugin + ${maven.release.version} + + clean verify + + + org.apache.maven.plugins maven-source-plugin - 3.3.0 + 3.0.1 + + + true + attach-sources @@ -672,9 +603,18 @@ org.apache.maven.plugins maven-javadoc-plugin 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 + 1024m + - attach-javadocs + bundle-sources + package jar @@ -682,11 +622,10 @@ - org.apache.maven.plugins maven-gpg-plugin + 3.0.1 sign-artifacts @@ -698,18 +637,24 @@ - - 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 + + + publish + deploy + + publish + + + diff --git a/publish.sh b/publish.sh new file mode 100755 index 000000000..da47e3a48 --- /dev/null +++ b/publish.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +mvn clean && mvn package -DskipTests -Dmaven.test.skip=true && mvn release:prepare -Prelease && mvn deploy -DperformRelease=true -DskipTests -Dmaven.test.skip=true diff --git a/src/main/java/com/zaxxer/hikari/pool/HikariPool.java b/src/main/java/com/zaxxer/hikari/pool/HikariPool.java index 27e3909ce..f55ee3cff 100644 --- a/src/main/java/com/zaxxer/hikari/pool/HikariPool.java +++ b/src/main/java/com/zaxxer/hikari/pool/HikariPool.java @@ -155,6 +155,10 @@ public Connection getConnection() throws SQLException */ public Connection getConnection(final long hardTimeout) throws SQLException { + if (poolState == POOL_SHUTDOWN) { + throw new SQLException("HikariPool " + this + " has been shut down."); + } + suspendResumeLock.acquire(); final var startTime = currentTime(); 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); 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/metrics/dropwizard/CodahaleHealthCheckerTest.java b/src/test/java/com/zaxxer/hikari/metrics/dropwizard/CodahaleHealthCheckerTest.java new file mode 100644 index 000000000..392df9d15 --- /dev/null +++ b/src/test/java/com/zaxxer/hikari/metrics/dropwizard/CodahaleHealthCheckerTest.java @@ -0,0 +1,38 @@ +package com.zaxxer.hikari.metrics.dropwizard; + +import com.codahale.metrics.health.HealthCheckRegistry; +import com.zaxxer.hikari.HikariConfig; +import com.zaxxer.hikari.HikariDataSource; +import org.junit.Test; + +import static com.zaxxer.hikari.pool.TestElf.newHikariConfig; +import static org.junit.Assert.assertTrue; + +public class CodahaleHealthCheckerTest +{ + @Test + public void testNoWaitForShutdownPool() + { + HealthCheckRegistry healthCheckRegistry = new HealthCheckRegistry(); + + HikariConfig config = newHikariConfig(); + config.setMinimumIdle(1); + config.setMaximumPoolSize(2); + config.setConnectionTestQuery("SELECT 1"); + config.setDataSourceClassName("org.h2.jdbcx.JdbcDataSource"); + config.addDataSourceProperty("url", "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1"); + config.setHealthCheckRegistry(healthCheckRegistry); + + String poolName; + + try (HikariDataSource ds = new HikariDataSource(config)) { + poolName = ds.getPoolName(); + } + + long currentTime = System.currentTimeMillis(); + healthCheckRegistry.runHealthCheck(poolName + ".pool.ConnectivityCheck"); + long elapsed = System.currentTimeMillis() - currentTime; + + assertTrue("Health check waited for timeout: " + elapsed + " ms", elapsed < 1000); + } +} 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( 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 @@ - +