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

markt-asf pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new c47acfd5a9 Better fix for test failures on Java 21 and earlier
c47acfd5a9 is described below

commit c47acfd5a91ea787b0c20972f6cea0bb569718d8
Author: Mark Thomas <[email protected]>
AuthorDate: Fri Sep 25 11:34:25 2026 +0100

    Better fix for test failures on Java 21 and earlier
---
 .../tribes/group/TestGroupChannelTlsFFM.java       | 28 ++++++++++++++++------
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/test/org/apache/catalina/tribes/group/TestGroupChannelTlsFFM.java 
b/test/org/apache/catalina/tribes/group/TestGroupChannelTlsFFM.java
index 58f345f69a..f44d88bbb3 100644
--- a/test/org/apache/catalina/tribes/group/TestGroupChannelTlsFFM.java
+++ b/test/org/apache/catalina/tribes/group/TestGroupChannelTlsFFM.java
@@ -25,37 +25,51 @@ import org.junit.runners.Parameterized;
 import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.compat.JreCompat;
 import org.apache.tomcat.util.net.openssl.OpenSSLStatus;
-import org.apache.tomcat.util.net.openssl.panama.OpenSSLLibrary;
 
 @RunWith(Parameterized.class)
 public class TestGroupChannelTlsFFM extends GroupChannelTlsTestBase {
 
     @Before
-    public void setup() {
+    public void setup() throws Exception {
         Assume.assumeTrue("FFM requires Java 22+", 
JreCompat.isJre22Available());
         if (explicit) {
             // Models starting cluster when OpenSSLLifecycleListener has 
configured FFM support.
-            OpenSSLLibrary.init();
+            openSSLLibraryInit();
             Assume.assumeTrue(OpenSSLStatus.isAvailable());
         } else {
             // Test FFM is available but leave it uninitialized so Tribes 
performs initialization
             try {
-                OpenSSLLibrary.init();
+                openSSLLibraryInit();
             } catch (Throwable t) {
                 ExceptionUtils.handleThrowable(t);
                 // Ignore
             }
             Assume.assumeTrue(OpenSSLStatus.isAvailable());
-            OpenSSLLibrary.destroy();
+            openSSLLibraryDestroy();
         }
     }
 
 
     @After
-    public void teardown() {
+    public void teardown() throws Exception {
         if (explicit) {
             // Models OpenSSLLifecycleListener. Stop FFM.
-            OpenSSLLibrary.destroy();
+            openSSLLibraryDestroy();
         }
     }
+
+
+    // Use reflection to avoid loading the FFM code (which has static 
initializers) before the Java 22 check.
+    private static void openSSLLibraryInit() throws Exception {
+        Class<?> openSSLLibraryClass =
+                
Class.forName("org.apache.tomcat.util.net.openssl.panama.OpenSSLLibrary");
+        openSSLLibraryClass.getMethod("init").invoke(null);
+    }
+
+
+    private static void openSSLLibraryDestroy() throws Exception {
+        Class<?> openSSLLibraryClass =
+                
Class.forName("org.apache.tomcat.util.net.openssl.panama.OpenSSLLibrary");
+        openSSLLibraryClass.getMethod("destroy").invoke(null);
+    }
 }


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

Reply via email to