suhasdantkale commented on a change in pull request #1254: ZOOKEEPER-2164:
Quorum members can not rejoin after restart
URL: https://github.com/apache/zookeeper/pull/1254#discussion_r380995250
##########
File path:
zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/QuorumCnxManager.java
##########
@@ -266,12 +267,33 @@ public static InitialMessage parse(Long protocolVersion,
DataInputStream din) th
} catch (ArrayIndexOutOfBoundsException e) {
throw new InitialMessageException("No port number in: %s",
addr);
}
- addresses.add(new InetSocketAddress(host_port[0], port));
+ if (!isWildcardAddress(host_port[0])) {
+ addresses.add(new InetSocketAddress(host_port[0], port));
+ }
}
return new InitialMessage(sid, addresses);
}
+ /**
+ * Returns true if the specified hostname is a wildcard address,
+ * like 0.0.0.0 for IPv4 or :: for IPv6
+ *
+ * (the function is package-private to be visible for testing)
+ */
+ static boolean isWildcardAddress(final String hostname) {
+ try {
+ return InetAddress.getByName(hostname).isAnyLocalAddress();
+ } catch (UnknownHostException e) {
+ // if we can not resolve, it can not be a wildcard address
+ return false;
Review comment:
I think if we cannot resolve this address, we should be still taking care of
not adding this address to the electionAddr() in the caller function - parse().
May be in that case should be return true from this function and change the
name of the function to reflect that(?)
Because in that case we are not only checking the wildcard addresses, but
also the unresolvable hostnames(?)
OR should we just have one Warning message here saying that the Initial
message has the unresolvable hostname(?)
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services