core/src/main/java/com/google/cloud/sql/core/CoreSocketFactory.java
@VisibleForTesting
  Socket createSslSocket(String instanceName, List<String> ipTypes) throws IOException {
    try {
      return createAndConfigureSocket(instanceName, ipTypes, CertificateCaching.USE_CACHE);
    } catch (SSLHandshakeException err) {
      logger.warning(
          String.format(
              "SSL handshake failed for Cloud SQL instance [%s], "
                  + "retrying with new certificate.\n%s",
              instanceName, Throwables.getStackTraceAsString(err)));

      if (!forcedRenewRateLimiter.tryAcquire()) {
        logger.warning(
            String.format(
                "Renewing too often, rate limiting certificate renewal for Cloud SQL "
                    + "instance [%s].",
                instanceName));
        forcedRenewRateLimiter.acquire();
      }
      return createAndConfigureSocket(instanceName, ipTypes, CertificateCaching.BYPASS_CACHE);
    }
  }
@VisibleForTesting
  Socket createSslSocket(String instanceName, List<String> ipTypes) throws IOException {
    try {
      return createAndConfigureSocket(instanceName, ipTypes, CertificateCaching.USE_CACHE);
    } catch (SSLHandshakeException err) {
      logger.warning(
          String.format(
              "SSL handshake failed for Cloud SQL instance [%s], "
                  + "retrying with new certificate.\n%s",
              instanceName, Throwables.getStackTraceAsString(err)));

      if (!forcedRenewRateLimiter.tryAcquire()) {
        logger.warning(
            String.format(
                "Renewing too often, rate limiting certificate renewal for Cloud SQL "
                    + "instance [%s].",
                instanceName));
        forcedRenewRateLimiter.acquire();
      }
      return createAndConfigureSocket(instanceName, ipTypes, CertificateCaching.BYPASS_CACHE);
    }
  }
TODO(berezv): separate creating socket and performing connection to make it easier to test