#vulnerable code 
                              public static void main(String[] args) throws Exception {

    SocksClientSSLUtil sslUtil = SocksClientSSLUtil.loadClassPath("client-ssl.properties");

    SocksProxy proxy = new Socks5(new InetSocketAddress("localhost", 1080));
    List<SocksMethod> methods = new ArrayList<SocksMethod>();
    methods.add(new NoAuthencationRequiredMethod());
    proxy.setAcceptableMethods(methods);
    SocksSocket socket = sslUtil.create(proxy);

    socket.connect("whois.internic.net", 43);
    InputStream inputStream = socket.getInputStream();
    OutputStream outputStream = socket.getOutputStream();
    PrintWriter printWriter = new PrintWriter(outputStream);
    printWriter.print("domain google.com\r\n");
    printWriter.flush();

    byte[] whoisrecords = new byte[2048];
    java.util.List<Byte> bytelist = new ArrayList<>(1024 * 6);
    int size = 0;
    while ((size = inputStream.read(whoisrecords)) > 0) {
      for (int i = 0; i < size; i++) {
        bytelist.add(whoisrecords[i]);
      }
    }
    byte[] resultbyte = new byte[bytelist.size()];
    for (int i = 0; i < resultbyte.length; i++) {
      resultbyte[i] = bytelist.get(i);
    }
    String string = new String(resultbyte);
    System.out.println(string);

    inputStream.close();
    outputStream.close();
    socket.close();
  } 
                            #location 35 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                              public static void main(String[] args) throws Exception {

    SSLConfiguration configuration = SSLConfiguration.loadClassPath("client-ssl.properties");
    
    SocksProxy proxy = new SSLSocks5(new InetSocketAddress("localhost", 1080), configuration);
    List<SocksMethod> methods = new ArrayList<SocksMethod>();
    methods.add(new NoAuthencationRequiredMethod());
    proxy.setAcceptableMethods(methods);
    SocksSocket socket = new SocksSocket(proxy);

    socket.connect("whois.internic.net", 43);
    InputStream inputStream = socket.getInputStream();
    OutputStream outputStream = socket.getOutputStream();
    PrintWriter printWriter = new PrintWriter(outputStream);
    printWriter.print("domain google.com\r\n");
    printWriter.flush();

    byte[] whoisrecords = new byte[2048];
    List<Byte> bytelist = new ArrayList<>(1024 * 6);
    int size = 0;
    while ((size = inputStream.read(whoisrecords)) > 0) {
      for (int i = 0; i < size; i++) {
        bytelist.add(whoisrecords[i]);
      }
    }
    byte[] resultbyte = new byte[bytelist.size()];
    for (int i = 0; i < resultbyte.length; i++) {
      resultbyte[i] = bytelist.get(i);
    }
    String string = new String(resultbyte);
    System.out.println(string);

    inputStream.close();
    outputStream.close();
    socket.close();
  }