#vulnerable code 
                              public static void main(String[] args) throws ExecutionException, InterruptedException, IOException {
    DnsSrvResolver resolver = DnsSrvResolvers.newBuilder()
        .cachingLookups(true)
        .retainingDataOnFailures(true)
        .metered(REPORTER)
        .dnsLookupTimeoutMillis(1000)
        .build();

    boolean quit = false;
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

    while (!quit) {
      System.out.print("Enter a SRV name: ");
      String line = in.readLine();

      if (line == null) {
        quit = true;
      } else {
        try {
          List<HostAndPort> nodes = resolver.resolve(line);

          for (HostAndPort node : nodes) {
            System.out.println(node);
          }
        }
        catch (DnsException e) {
          e.printStackTrace(System.out);
        }
      }
    }
  } 
                            #location 24 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                              public static void main(String[] args) throws ExecutionException, InterruptedException, IOException {
    DnsSrvResolver resolver = DnsSrvResolvers.newBuilder()
        .cachingLookups(true)
        .retainingDataOnFailures(true)
        .metered(REPORTER)
        .dnsLookupTimeoutMillis(1000)
        .build();

    boolean quit = false;
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

    while (!quit) {
      System.out.print("Enter a SRV name: ");
      String line = in.readLine();

      if (line == null || line.isEmpty()) {
        quit = true;
      } else {
        try {
          List<HostAndPort> nodes = resolver.resolve(line);

          for (HostAndPort node : nodes) {
            System.out.println(node);
          }
        }
        catch (DnsException e) {
          e.printStackTrace(System.out);
        }
      }
    }
  }