Skip to content

Commit f671213

Browse files
committed
Re-work fix to use existing Tomcat 9 approach - it is cleaner
1 parent 6ab7dc9 commit f671213

1 file changed

Lines changed: 4 additions & 17 deletions

File tree

test/org/apache/tomcat/util/net/TestSslHandshakeFailure.java

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import javax.net.ssl.SSLContext;
2727
import javax.net.ssl.SSLHandshakeException;
2828

29-
import org.junit.Assert;
3029
import org.junit.Test;
3130
import org.junit.runners.Parameterized;
3231
import org.junit.runners.Parameterized.Parameter;
@@ -78,24 +77,12 @@ public void testMissingClientCertificate() throws Exception {
7877
sc.init(null, TesterSupport.getTrustManagers(), null);
7978
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
8079

81-
Throwable actual = null;
8280
try {
8381
getUrl("https://localhost:" + getPort() + "/");
84-
} catch (Throwable t) {
85-
actual = t;
86-
}
87-
88-
/*
89-
* SSLHandshakeException expected but SocketException has been observed
90-
*/
91-
Assert.assertNotNull("No exception was thrown when SSLHandshakeException was expected", actual);
92-
93-
if (actual instanceof SSLHandshakeException || actual instanceof SocketException) {
94-
// Tests passes = NO-OP
95-
} else {
96-
actual.printStackTrace();
97-
Assert.fail("Unexpected exception [" + actual.getClass() + ": " + actual.getMessage() + "].");
82+
} catch (SSLHandshakeException t) {
83+
// Expected
84+
} catch (SocketException e) {
85+
// Expected - SocketException has also been observed (less often)
9886
}
9987
}
100-
10188
}

0 commit comments

Comments
 (0)