Created
August 14, 2019 00:23
-
-
Save sh0seo/64f5923cf1107423ee69cac5ee049f0b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private int getAndSetNetworkTimeout(Connection connection, long timeoutMs) { | |
if (this.isNetworkTimeoutSupported != 0) { | |
try { | |
int originalTimeout = connection.getNetworkTimeout(); | |
connection.setNetworkTimeout(this.netTimeoutExecutor, (int)timeoutMs); | |
this.isNetworkTimeoutSupported = 1; | |
return originalTimeout; | |
} catch (AbstractMethodError | Exception var5) { | |
if (this.isNetworkTimeoutSupported == -1) { | |
this.isNetworkTimeoutSupported = 0; | |
this.logger.info("{} - Driver does not support get/set network timeout for connections. ({})", this.poolName, var5.getMessage()); | |
if (this.validationTimeout < TimeUnit.SECONDS.toMillis(1L)) { | |
this.logger.warn("{} - A validationTimeout of less than 1 second cannot be honored on drivers without setNetworkTimeout() support.", this.poolName); | |
} else if (this.validationTimeout % TimeUnit.SECONDS.toMillis(1L) != 0L) { | |
this.logger.warn("{} - A validationTimeout with fractional second granularity cannot be honored on drivers without setNetworkTimeout() support.", this.poolName); | |
} | |
} | |
} | |
} | |
return 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment