Skip to content

Commit

Permalink
Synchronize idleTimeout manipulation methods
Browse files Browse the repository at this point in the history
  • Loading branch information
brettwooldridge committed Aug 4, 2021
1 parent bab9f64 commit 7a0a156
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/zaxxer/hikari/HikariConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/zaxxer/hikari/db/BasicPoolTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down

0 comments on commit 7a0a156

Please sign in to comment.