File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
client/rest/src/test/java/org/elasticsearch/client Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 3535import java .io .StringWriter ;
3636import java .net .SocketTimeoutException ;
3737import java .net .URISyntaxException ;
38+ import javax .net .ssl .SSLHandshakeException ;
3839
3940import static org .junit .Assert .assertEquals ;
4041import static org .junit .Assert .assertNotNull ;
@@ -211,6 +212,23 @@ public void testConnectionClosedExceptionIsWrapped() throws Exception {
211212 }
212213 }
213214
215+ public void testSSLHandshakeExceptionIsWrapped () throws Exception {
216+ RestClient .SyncResponseListener syncResponseListener = new RestClient .SyncResponseListener (10000 );
217+ SSLHandshakeException exception = new SSLHandshakeException (randomAsciiAlphanumOfLength (5 ));
218+ syncResponseListener .onFailure (exception );
219+ try {
220+ syncResponseListener .get ();
221+ fail ("get should have failed" );
222+ } catch (SSLHandshakeException e ) {
223+ // We preserve the original exception in the cause
224+ assertSame (exception , e .getCause ());
225+ // We copy the message
226+ assertEquals (exception .getMessage (), e .getMessage ());
227+ // And we do all that so the thrown exception has our method in the stacktrace
228+ assertExceptionStackContainsCallingMethod (e );
229+ }
230+ }
231+
214232 public void testIOExceptionIsBuiltCorrectly () throws Exception {
215233 RestClient .SyncResponseListener syncResponseListener = new RestClient .SyncResponseListener (10000 );
216234 IOException ioException = new IOException ();
You can’t perform that action at this time.
0 commit comments