File tree 1 file changed +18
-0
lines changed
client/rest/src/test/java/org/elasticsearch/client
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 35
35
import java .io .StringWriter ;
36
36
import java .net .SocketTimeoutException ;
37
37
import java .net .URISyntaxException ;
38
+ import javax .net .ssl .SSLHandshakeException ;
38
39
39
40
import static org .junit .Assert .assertEquals ;
40
41
import static org .junit .Assert .assertNotNull ;
@@ -211,6 +212,23 @@ public void testConnectionClosedExceptionIsWrapped() throws Exception {
211
212
}
212
213
}
213
214
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
+
214
232
public void testIOExceptionIsBuiltCorrectly () throws Exception {
215
233
RestClient .SyncResponseListener syncResponseListener = new RestClient .SyncResponseListener (10000 );
216
234
IOException ioException = new IOException ();
You can’t perform that action at this time.
0 commit comments