zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anmolnar <...@git.apache.org>
Subject [GitHub] zookeeper pull request #534: ZOOKEEPER-2184 Zookeeper Client should re-resol...
Date Mon, 18 Jun 2018 11:57:55 GMT
Github user anmolnar commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/534#discussion_r196050719
  
    --- Diff: src/java/main/org/apache/zookeeper/client/StaticHostProvider.java ---
    @@ -149,15 +185,12 @@ public StaticHostProvider(Collection<InetSocketAddress> serverAddresses,
          * @param currentHost the host to which this client is currently connected
          * @return true if changing connections is necessary for load-balancing, false otherwise
 
          */
    -
    -
         @Override
         public synchronized boolean updateServerList(
                 Collection<InetSocketAddress> serverAddresses,
                 InetSocketAddress currentHost) {
    -        // Resolve server addresses and shuffle them
    -        List<InetSocketAddress> resolvedList = resolveAndShuffle(serverAddresses);
    -        if (resolvedList.isEmpty()) {
    +        List<InetSocketAddress> shuffledList = shuffle(serverAddresses);
    --- End diff --
    
    Comparison works for unresolved addresses too, because of the last if condition here:
    ```java
    if (addr.getPort() == myServer.getPort()
        && ((addr.getAddress() != null
        && myServer.getAddress() != null && addr
        .getAddress().equals(myServer.getAddress())) || addr
        .getHostString().equals(myServer.getHostString()))) {
    ```
    As long as `getHostString()` works for unresolved addresses, we're fine. However, exactly
the same functionality has already been implemented in the `InetSocketAddress.equals()` method,
so  I refactored this part to use it.


---

Mime
View raw message