symat 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_r381860093
##########
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) {
Review comment:
good question... that is an unchecked exception, which I think kind of
indicate that we will not be able to start ZooKeeper properly. I am fine just
simply die in this case (most probably in this case we will never reach this
point). But adding an extra log here can not hurt...
----------------------------------------------------------------
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