searchbox-io / Jest

Elasticsearch Java Rest Client.
Apache License 2.0
2.11k stars 727 forks source link

Node host unresolved fails to trigger CouldNotConnectException #494

Open andrejserafim opened 7 years ago

andrejserafim commented 7 years ago

Specific exception below.

This is a special case of https://github.com/searchbox-io/Jest/issues/329, but since it's special I'm hoping we can resolve it easier.

13:39:41.486 [NodeChecker RUNNING] [] ERROR i.s.c.config.discovery.NodeChecker - Error executing NodesInfo!
java.net.UnknownHostException: elasticsearch: Temporary failure in name resolution
    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.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45)
    at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:111)
    at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
    at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
    at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107)
    at io.searchbox.client.http.JestHttpClient.executeRequest(JestHttpClient.java:109)
    at io.searchbox.client.http.JestHttpClient.execute(JestHttpClient.java:56)
    at io.searchbox.client.config.discovery.NodeChecker.runOneIteration(NodeChecker.java:66)
    at com.google.common.util.concurrent.AbstractScheduledService$ServiceDelegate$Task.run(AbstractScheduledService.java:189)
    at com.google.common.util.concurrent.Callables$3.run(Callables.java:100)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
andrejserafim commented 7 years ago

My idea of a fix here is rather specific - add UknownHostException to the catch list in io.searchbox.client.http.JestHttpClient#execute. Happy to submit a PR. Let me know what you think.

andrejserafim commented 7 years ago

@ferhatsb wdyt?