diff --git a/src/main/java/com/zaxxer/hikari/HikariConfig.java b/src/main/java/com/zaxxer/hikari/HikariConfig.java index e2b34dc7d..6f6c3879a 100644 --- a/src/main/java/com/zaxxer/hikari/HikariConfig.java +++ b/src/main/java/com/zaxxer/hikari/HikariConfig.java @@ -194,14 +194,14 @@ else if (connectionTimeoutMs < SOFT_TIMEOUT_FLOOR) { /** {@inheritDoc} */ @Override - public long getIdleTimeout() + public synchronized long getIdleTimeout() { return idleTimeout; } /** {@inheritDoc} */ @Override - public void setIdleTimeout(long idleTimeoutMs) + public synchronized void setIdleTimeout(long idleTimeoutMs) { if (idleTimeoutMs < 0) { throw new IllegalArgumentException("idleTimeout cannot be negative"); diff --git a/src/test/java/com/zaxxer/hikari/db/BasicPoolTest.java b/src/test/java/com/zaxxer/hikari/db/BasicPoolTest.java index 07c530b99..ececa0fe0 100644 --- a/src/test/java/com/zaxxer/hikari/db/BasicPoolTest.java +++ b/src/test/java/com/zaxxer/hikari/db/BasicPoolTest.java @@ -77,14 +77,14 @@ public void testIdleTimeout() throws InterruptedException, SQLException System.setProperty("com.zaxxer.hikari.housekeeping.periodMs", "1000"); try (HikariDataSource ds = new HikariDataSource(config)) { + getUnsealedConfig(ds).setIdleTimeout(3000); + System.clearProperty("com.zaxxer.hikari.housekeeping.periodMs"); SECONDS.sleep(1); HikariPool pool = getPool(ds); - getUnsealedConfig(ds).setIdleTimeout(3000); - assertEquals("Total connections not as expected", 5, pool.getTotalConnections()); assertEquals("Idle connections not as expected", 5, pool.getIdleConnections());