code: private String readEc2MetadataUrl(URL url, int connectionTimeoutMs, int readTimeoutMs) throws IOException {
  
          if (url.getProtocol().equalsIgnoreCase("file")) {
              url = rewriteUrl(url);
              URLConnection urlConnection = url.openConnection();
              urlConnection.connect();
              try (BufferedReader in = new BufferedReader(
                  new InputStreamReader(urlConnection.getInputStream()))) {
                  return IOUtils.readText(in);
              }
          } else {
              URLConnection urlConnection = url.openConnection();
              HttpURLConnection uc = (HttpURLConnection) urlConnection;
  
              uc.setConnectTimeout(connectionTimeoutMs);
              uc.setReadTimeout(readTimeoutMs);
              uc.setRequestMethod("GET");
              uc.setDoOutput(true);
              int responseCode = uc.getResponseCode();
              try (BufferedReader in = new BufferedReader(
                  new InputStreamReader(uc.getInputStream()))) {
                  return IOUtils.readText(in);
              }
          }
      }
docs: Read EC2 metadata from the given URL.
  
  @param url URL to fetch AWS EC2 metadata information
  @param connectionTimeoutMs connection timeout in millis
  @param readTimeoutMs read timeout in millis
  @return AWS EC2 metadata information
  @throws IOException Signals that an I/O exception of some sort has occurred