File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed
wrapper/src/main/java/software/amazon/jdbc/plugin/efm2 Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ public class HostMonitorImpl extends AbstractMonitor implements HostMonitor {
5252 private static final long THREAD_SLEEP_NANO = TimeUnit .MILLISECONDS .toNanos (100 );
5353 private static final long TERMINATION_TIMEOUT_SEC = 30 ;
5454 private static final String MONITORING_PROPERTY_PREFIX = "monitoring-" ;
55+ private static final int MIN_VALIDITY_CHECK_TIMEOUT_SEC = 1 ;
5556
5657 protected static final Executor ABORT_EXECUTOR =
5758 ExecutorFactory .newSingleThreadExecutor ("abort" );
@@ -323,7 +324,8 @@ boolean checkConnectionStatus() {
323324 // Some drivers, like MySQL Connector/J, execute isValid() in a double of specified timeout time.
324325 final int validTimeout = (int ) TimeUnit .NANOSECONDS .toSeconds (
325326 this .failureDetectionIntervalNano - THREAD_SLEEP_NANO ) / 2 ;
326- return this .monitoringConn .isValid (validTimeout );
327+ // validTimeout could get rounded down to 0.
328+ return this .monitoringConn .isValid (Math .max (MIN_VALIDITY_CHECK_TIMEOUT_SEC , validTimeout ));
327329 } catch (final SQLException sqlEx ) {
328330 return false ;
329331 } finally {
You can’t perform that action at this time.
0 commit comments