From cd165d1c4bda6a6dd3fbae4652285889b839148a Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Sat, 17 Mar 2018 11:06:05 -0400 Subject: [PATCH] Client: Wrap SSLHandshakeException in sync calls Adds SSLHandshakeException to the list of Exceptions that are specifically rethrown from the async thread so its type is preserved. This should make it easier to debug synchronous calls with ssl issues. --- .../src/main/java/org/elasticsearch/client/RestClient.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/client/rest/src/main/java/org/elasticsearch/client/RestClient.java b/client/rest/src/main/java/org/elasticsearch/client/RestClient.java index 29e23f948bd..4aa1a9d815c 100644 --- a/client/rest/src/main/java/org/elasticsearch/client/RestClient.java +++ b/client/rest/src/main/java/org/elasticsearch/client/RestClient.java @@ -72,6 +72,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; +import javax.net.ssl.SSLHandshakeException; /** * Client that connects to an Elasticsearch cluster through HTTP. @@ -717,6 +718,11 @@ public class RestClient implements Closeable { e.initCause(exception); throw e; } + if (exception instanceof SSLHandshakeException) { + SSLHandshakeException e = new SSLHandshakeException(exception.getMessage()); + e.initCause(exception); + throw e; + } if (exception instanceof IOException) { throw new IOException(exception.getMessage(), exception); }