Skip to content

Commit

Permalink
Fix #1818 Add system property for minimum login timeout, regardless o…
Browse files Browse the repository at this point in the history
…f the connectionTimeout (#1820)
  • Loading branch information
bananayong committed Sep 15, 2023
1 parent 8c202e4 commit 5b2852e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/java/com/zaxxer/hikari/pool/PoolBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ abstract class PoolBase
private static final int UNINITIALIZED = -1;
private static final int TRUE = 1;
private static final int FALSE = 0;
private static final int MINIMUM_LOGIN_TIMEOUT = Integer.getInteger("com.zaxxer.hikari.minimumLoginTimeoutSecs", 1);

private int networkTimeout;
private int isNetworkTimeoutSupported;
Expand Down Expand Up @@ -616,7 +617,7 @@ private void setLoginTimeout(final DataSource dataSource)
{
if (connectionTimeout != Integer.MAX_VALUE) {
try {
dataSource.setLoginTimeout(Math.max(1, (int) MILLISECONDS.toSeconds(500L + connectionTimeout)));
dataSource.setLoginTimeout(Math.max(MINIMUM_LOGIN_TIMEOUT, (int) MILLISECONDS.toSeconds(500L + connectionTimeout)));
}
catch (Exception e) {
logger.info("{} - Failed to set login timeout for data source. ({})", poolName, e.getMessage());
Expand Down

0 comments on commit 5b2852e

Please sign in to comment.