in core/src/main/java/com/google/cloud/sql/core/RefreshAheadStrategy.java [119:152]
public ConnectionInfo getConnectionInfo(long timeoutMs) {
ListenableFuture<ConnectionInfo> f;
synchronized (connectionInfoGuard) {
if (closed) {
throw new IllegalStateException("Named connection closed");
}
f = current;
}
try {
return f.get(timeoutMs, TimeUnit.MILLISECONDS);
} catch (TimeoutException e) {
synchronized (connectionInfoGuard) {
if (currentRefreshFailure != null) {
throw new RuntimeException(
String.format(
"Unable to get valid instance data within %d ms."
+ " Last refresh attempt failed:",
timeoutMs)
+ currentRefreshFailure.getMessage(),
currentRefreshFailure);
}
}
throw new RuntimeException(
String.format(
"Unable to get valid instance data within %d ms. No refresh has completed.",
timeoutMs),
e);
} catch (ExecutionException | InterruptedException ex) {
Throwable cause = ex.getCause();
Throwables.throwIfUnchecked(cause);
throw new RuntimeException(cause);
}
}