private static boolean isValid(SocketAddress address) {
    if (address instanceof InetSocketAddress) {
      /*
       * NOTE: On some platforms with java.net.useSystemProxies=true, unconfigured proxies show up as proxy
       * objects with empty host and port 0.
       */
      final InetSocketAddress addr = (InetSocketAddress)address;
      String hostString = addr.getHostString();
      return addr.getPort() > 0 && hostString != null && !hostString.isEmpty();
    }
    return false;
  }
private static boolean isValid(SocketAddress address)