@@ -84,29 +84,23 @@ public void multipleSSLWithoutCacheTest() throws Exception {
84
84
85
85
@ Test (groups = { "standalone" , "default_provider" })
86
86
public void reconnectsAfterFailedCertificationPath () throws Exception {
87
- AtomicBoolean trusted = new AtomicBoolean (false );
88
- try (AsyncHttpClient c = getAsyncHttpClient (new Builder ().setSSLContext (createSSLContext (trusted )).build ())) {
87
+
88
+ AtomicBoolean trust = new AtomicBoolean (false );
89
+ try (AsyncHttpClient client = getAsyncHttpClient (new Builder ().setSSLContext (createSSLContext (trust )).build ())) {
89
90
String body = "hello there" ;
90
91
91
92
// first request fails because server certificate is rejected
92
93
Throwable cause = null ;
93
94
try {
94
- c .preparePost (getTargetUrl ()).setBody (body ).setHeader ("Content-Type" , "text/html" ).execute ().get (TIMEOUT , TimeUnit .SECONDS );
95
+ client .preparePost (getTargetUrl ()).setBody (body ).setHeader ("Content-Type" , "text/html" ).execute ().get (TIMEOUT , TimeUnit .SECONDS );
95
96
} catch (final ExecutionException e ) {
96
97
cause = e .getCause ();
97
- if (cause instanceof ConnectException ) {
98
- //assertNotNull(cause.getCause());
99
- assertTrue (cause .getCause () instanceof SSLHandshakeException , "Expected an SSLHandshakeException, got a " + cause .getCause ());
100
- } else {
101
- assertTrue (cause instanceof IOException , "Expected an IOException, got a " + cause );
102
- }
103
98
}
104
- assertNotNull (cause );
105
-
106
- trusted .set (true );
99
+ assertTrue (cause instanceof SSLHandshakeException , "Expected an SSLHandshakeException, got a " + cause );
107
100
108
101
// second request should succeed
109
- Response response = c .preparePost (getTargetUrl ()).setBody (body ).setHeader ("Content-Type" , "text/html" ).execute ().get (TIMEOUT , TimeUnit .SECONDS );
102
+ trust .set (true );
103
+ Response response = client .preparePost (getTargetUrl ()).setBody (body ).setHeader ("Content-Type" , "text/html" ).execute ().get (TIMEOUT , TimeUnit .SECONDS );
110
104
111
105
assertEquals (response .getResponseBody (), body );
112
106
}
0 commit comments