Github user maoling commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/489#discussion_r194247374
  
    --- Diff: 
src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java ---
    @@ -222,15 +222,15 @@ static public InitialMessage parse(Long 
protocolVersion, DataInputStream din)
                             num_read, remaining, sid);
                 }
     
    -            // FIXME: IPv6 is not supported. Using something like Guava's 
HostAndPort
    -            //        parser would be good.
                 String addr = new String(b);
    -            String[] host_port = addr.split(":");
    -
    -            if (host_port.length != 2) {
    -                throw new InitialMessageException("Badly formed address: 
%s", addr);
    +            int pos = addr.lastIndexOf(":");
    +           
    +            if (pos == -1 || pos + 1  == (addr.length() )) {
    --- End diff --
    
    1. "I think the better way to do this is updating the initiateConnection 
function to pass in IPv6 literal address "[%s]:%s" -----pardon me.I don't get 
your idea.
    2."here we can use QuorumPeer.splitWithLeadingHostname to check and get 
IPv6 host and port."-----IMHO,we should have a common class in the 
org.apache.zookeeper.server.util package which just like 
(HostAndPort#getHostAndPortFromBracketedHost)[https://github.com/google/guava/blob/master/guava/src/com/google/common/net/HostAndPort.java]
 does,then QuorumPeer.splitWithLeadingHostname , 
QuorumCnxManager.InitialMessage.parse and others can reuse it.


---

Reply via email to