sgroschupf / zkclient

a zookeeper client, that makes life a little easier.
www.datameer.com
Apache License 2.0
1.09k stars 493 forks source link

zkclient throws an UnknownHostException if one of the servers in zkConnectionString doesn't resolve #72

Closed harshach closed 6 years ago

harshach commented 6 years ago

It looks like zkclient bubbling up the zookeeper error even if one of the hosts failed to resolve org.I0Itec.zkclient.exception.ZkException: Unable to connect to {quorum} at org.I0Itec.zkclient.ZkConnection.connect(ZkConnection.java:72) at org.I0Itec.zkclient.ZkClient.reconnect(ZkClient.java:1289) at org.I0Itec.zkclient.ZkClient.processStateChanged(ZkClient.java:721) at org.I0Itec.zkclient.ZkClient.process(ZkClient.java:632) at org.apache.zookeeper.ClientCnxn$EventThread.processEvent(ClientCnxn.java:530) at org.apache.zookeeper.ClientCnxn$EventThread.run(ClientCnxn.java:505) Caused by: java.net.UnknownHostException: {hostname} : unknown error at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928) at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323) at java.net.InetAddress.getAllByName0(InetAddress.java:1276) at java.net.InetAddress.getAllByName(InetAddress.java:1192) at java.net.InetAddress.getAllByName(InetAddress.java:1126) at org.apache.zookeeper.client.StaticHostProvider.(StaticHostProvider.java:61) at org.apache.zookeeper.ZooKeeper.(ZooKeeper.java:445) at org.apache.zookeeper.ZooKeeper.(ZooKeeper.java:380) at org.I0Itec.zkclient.ZkConnection.connect(ZkConnection.java:70)

It did get fixed in zookeeper 3.5.0 https://issues.apache.org/jira/browse/ZOOKEEPER-1576 but 3.5.0 is still in beta. I am happy to provide a similar fix in zkClient until we upgrade to 3.5.0. Let me know if it can be acceptable fix.

harshach commented 6 years ago

PR available here

jzillmann commented 6 years ago

Merged!