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.
---