if (value.startsWith("[")) {
// bracketed IPv6 (with port number)
int i = value.lastIndexOf(']');
if (i == -1) {
throw new InvalidFormatException("Bracketed IPv6 address must contain closing bracket",
value, InetSocketAddress.class);
}
int j = value.indexOf(':', i);
int port = j > -1 ? Integer.parseInt(value.substring(j + 1)) : 0;