code: private static String[] getHostAndPortFromBracketedHost(String hostPortString) {
      int colonIndex = 0;
      int closeBracketIndex = 0;
      checkArgument(
          hostPortString.charAt(0) == '[',
          "Bracketed host-port string must start with a bracket: %s",
          hostPortString);
      colonIndex = hostPortString.indexOf(':');
      closeBracketIndex = hostPortString.lastIndexOf(']');
      checkArgument(
          colonIndex > -1 && closeBracketIndex > colonIndex,
          "Invalid bracketed host/port: %s",
          hostPortString);
  
      String host = hostPortString.substring(1, closeBracketIndex);
      if (closeBracketIndex + 1 == hostPortString.length()) {
        return new String[] {host, ""};
      } else {
        checkArgument(
            hostPortString.charAt(closeBracketIndex + 1) == ':',
            "Only a colon may follow a close bracket: %s",
            hostPortString);
        for (int i = closeBracketIndex + 2; i < hostPortString.length(); ++i) {
          checkArgument(
              Character.isDigit(hostPortString.charAt(i)),
              "Port must be numeric: %s",
              hostPortString);
        }
        return new String[] {host, hostPortString.substring(closeBracketIndex + 2)};
      }
    }
docs: Parses a bracketed host-port string, throwing IllegalArgumentException if parsing fails.
  
  @param hostPortString the full bracketed host-port specification. Post might not be specified.
  @return an array with 2 strings: host and port, in that order.
  @throws IllegalArgumentException if parsing the bracketed host-port string fails.