This is an automated email from the ASF dual-hosted git repository.

rainerjung pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/9.0.x by this push:
     new 0c3339a1e1 Improve test reliability with Java 8
0c3339a1e1 is described below

commit 0c3339a1e10824c69cb83fe6c8b578c791b0de59
Author: Rainer Jung <[email protected]>
AuthorDate: Sun May 3 15:28:29 2026 +0200

    Improve test reliability with Java 8
---
 .../apache/tomcat/util/net/TestSslHandshakeFailure.java  | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/test/org/apache/tomcat/util/net/TestSslHandshakeFailure.java 
b/test/org/apache/tomcat/util/net/TestSslHandshakeFailure.java
index cd372446cd..2e9f7ae9e3 100644
--- a/test/org/apache/tomcat/util/net/TestSslHandshakeFailure.java
+++ b/test/org/apache/tomcat/util/net/TestSslHandshakeFailure.java
@@ -23,8 +23,10 @@ import java.util.List;
 
 import javax.net.ssl.HttpsURLConnection;
 import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLException;
 import javax.net.ssl.SSLHandshakeException;
 
+import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameter;
@@ -32,6 +34,7 @@ import org.junit.runners.Parameterized.Parameter;
 import org.apache.catalina.Context;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
+import org.apache.tomcat.util.compat.JreCompat;
 
 public class TestSslHandshakeFailure extends TomcatBaseTest {
 
@@ -57,7 +60,7 @@ public class TestSslHandshakeFailure extends TomcatBaseTest {
     @Parameter(2)
     public String sslImplementationName;
 
-    @Test(expected = SSLHandshakeException.class)
+    @Test
     public void testMissingClientCertificate() throws Exception {
         Tomcat tomcat = getTomcatInstance();
 
@@ -76,7 +79,16 @@ public class TestSslHandshakeFailure extends TomcatBaseTest {
         sc.init(null, TesterSupport.getTrustManagers(), null);
         HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
 
-        getUrl("https://localhost:"; + getPort() + "/");
+        try {
+            getUrl("https://localhost:"; + getPort() + "/");
+            Assert.fail("SSLHandshakeException expected, but handshake did not 
fail");
+        } catch (SSLHandshakeException e) {
+        // Java 8 might throw SSLException instead of SSLHandshakeException
+        } catch (SSLException e) {
+            if (JreCompat.isJre9Available()) {
+                throw(e);
+            }
+        }
 
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to