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

    https://github.com/apache/zookeeper/pull/451#discussion_r186591847
  
    --- Diff: src/java/main/org/apache/zookeeper/client/StaticHostProvider.java 
---
    @@ -111,9 +154,18 @@ public InetSocketAddress next(long spinDelay) {
                 lastIndex = 0;
             }
     
    -        return serverAddresses.get(currentIndex);
    +        InetSocketAddress curAddr = serverAddresses.get(currentIndex);
    +
    +        String curHostString = getHostString(curAddr);
    +        List<InetAddress> resolvedAddresses = new 
ArrayList<InetAddress>(Arrays.asList(this.resolver.getAllByName(curHostString)));
    +        if (resolvedAddresses.isEmpty()) {
    +            throw new UnknownHostException("No IP address returned for 
address: " + curHostString);
    +        }
    +        Collections.shuffle(resolvedAddresses);
    --- End diff --
    
    Correctly configured DNS servers return multiple IP addresses in round 
robin fashion for a single hostname, so shuffle is not needed. However there 
was a concern of badly configured DNS servers might not do this properly and we 
want to workaround it here.


---

Reply via email to