You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zookeeper.apache.org by anmolnar <gi...@git.apache.org> on 2018/02/04 13:45:04 UTC
[GitHub] zookeeper pull request #448: client: do not try to connect to an unreachable...
Github user anmolnar commented on a diff in the pull request:
https://github.com/apache/zookeeper/pull/448#discussion_r165844761
--- Diff: src/java/main/org/apache/zookeeper/client/StaticHostProvider.java ---
@@ -107,16 +112,43 @@ public StaticHostProvider(Collection<InetSocketAddress> serverAddresses,
lastIndex = -1;
}
+ private Set<Class<? extends InetAddress>> supportedAddressTypes() {
+ Set<Class<? extends InetAddress>> types = new HashSet<>();
+ try {
+ Enumeration<NetworkInterface> inets = NetworkInterface.getNetworkInterfaces();
+ while (inets.hasMoreElements()) {
+ NetworkInterface ne = inets.nextElement();
+
+ Enumeration<InetAddress> addrs = ne.getInetAddresses();
+ while (addrs.hasMoreElements()) {
+ InetAddress addr = addrs.nextElement();
+ if (addr.isLinkLocalAddress() || addr.isLoopbackAddress()) {
+ continue;
+ }
+ types.add(addr.getClass());
+ }
+ }
+ } catch (SocketException e) {
+ LOG.error("Failed to resolve supported address types: ", e);
--- End diff --
Catching this exception here could result the method returning empty list of supported address types which later will make the client unable to connect to any servers.
I think the client should be terminated either in the case of empty list or the first time when this is exception is caught.
---