in wrapper/src/main/java/software/amazon/jdbc/plugin/AuroraConnectionTrackerPlugin.java [110:152]
public <T, E extends Exception> T execute(final Class<T> resultClass, final Class<E> exceptionClass,
final Object methodInvokeOn, final String methodName, final JdbcCallable<T, E> jdbcMethodFunc,
final Object[] jdbcMethodArgs) throws E {
final HostSpec currentHostSpec = this.pluginService.getCurrentHostSpec();
this.rememberWriter();
try {
if (!methodName.equals(METHOD_CLOSE) && !methodName.equals(METHOD_ABORT)) {
long localHostListRefreshEndTimeNano = hostListRefreshEndTimeNano.get();
boolean needRefreshHostLists = false;
if (localHostListRefreshEndTimeNano > 0) {
if (localHostListRefreshEndTimeNano > System.nanoTime()) {
// The time specified in hostListRefreshThresholdTimeNano isn't yet reached.
// Need to continue to refresh host list.
needRefreshHostLists = true;
} else {
// The time specified in hostListRefreshThresholdTimeNano is reached, and we can stop further refreshes
// of host list. If hostListRefreshThresholdTimeNano has changed while this thread processes the code,
// we can't override a new value in hostListRefreshThresholdTimeNano.
hostListRefreshEndTimeNano.compareAndSet(localHostListRefreshEndTimeNano, 0);
}
}
if (this.needUpdateCurrentWriter || needRefreshHostLists) {
// Calling this method may effectively close/abort a current connection
this.checkWriterChanged(needRefreshHostLists);
}
}
final T result = jdbcMethodFunc.call();
if ((methodName.equals(METHOD_CLOSE) || methodName.equals(METHOD_ABORT))) {
tracker.removeConnectionTracking(currentHostSpec, this.pluginService.getCurrentConnection());
}
return result;
} catch (final Exception e) {
if (e instanceof FailoverSQLException) {
hostListRefreshEndTimeNano.set(System.nanoTime() + TOPOLOGY_CHANGES_EXPECTED_TIME_NANO);
// Calling this method may effectively close/abort a current connection
this.checkWriterChanged(true);
}
throw e;
}
}