in core/src/main/java/com/google/cloud/sql/core/Connector.java [153:177]
MonitoredCache getConnection(final ConnectionConfig config) {
final ConnectionConfig updatedConfig = resolveConnectionName(config);
// If the cache entry doesn't exist, or if the cache entry is closed,
// replace it.
MonitoredCache instance =
instances.compute(
updatedConfig,
(k, v) ->
v != null && !v.isClosed()
? v
: new MonitoredCache(
createConnectionInfo(updatedConfig),
instanceNameResolverTimer,
this::resolveDomain));
// If the client certificate has expired (as when the computer goes to
// sleep, and the refresh cycle cannot run), force a refresh immediately.
// The TLS handshake will not fail on an expired client certificate. It's
// not until the first read where the client cert error will be surfaced.
// So check that the certificate is valid before proceeding.
instance.refreshIfExpired();
return instance;
}