wangjialing218 commented on code in PR #3158: URL: https://github.com/apache/bookkeeper/pull/3158#discussion_r931021142
########## bookkeeper-common/src/main/java/org/apache/bookkeeper/common/net/ServiceURI.java: ########## @@ -145,6 +146,39 @@ public class ServiceURI { public static ServiceURI create(String uriStr) { checkNotNull(uriStr, "service uri string is null"); + if (uriStr.contains("[") && uriStr.contains("]")) { + // deal with ipv6 address + Splitter splitter = Splitter.on(CharMatcher.anyOf(",;")); + List<String> hosts = splitter.splitToList(uriStr); + + if (hosts.size() > 1) { + // deal with multi ipv6 hosts + String firstHost = hosts.get(0); + String lastHost = hosts.get(hosts.size() - 1); + boolean hasPath = lastHost.contains("/"); + String path = hasPath ? lastHost.substring(lastHost.indexOf("/")) : ""; + firstHost += path; + + URI uri = URI.create(firstHost); + ServiceURI serviceURI = create(uri); + + List<String> multiHosts = new ArrayList<>(); + multiHosts.add(serviceURI.getServiceHosts()[0]); + multiHosts.addAll(hosts.subList(1, hosts.size())); + multiHosts = multiHosts + .stream() + .map(host -> validateHostName(serviceURI.getServiceName(), host)) + .collect(Collectors.toList()); + return new ServiceURI( + serviceURI.getServiceName(), + serviceURI.getServiceInfos(), + serviceURI.getServiceUser(), + multiHosts.toArray(new String[multiHosts.size()]), + serviceURI.getServicePath(), + serviceURI.getUri()); + } Review Comment: No, `URI.create(uriStr)` could handle this case, `testIPv6Address()` cover this test case -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@bookkeeper.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org