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

markt 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 88c948750e Ensure tomcat-jni.jar is not required by catalina.jar
88c948750e is described below

commit 88c948750e7b9fc7d3dde0b337593b468476e691
Author: Mark Thomas <[email protected]>
AuthorDate: Mon Nov 24 17:12:37 2025 +0000

    Ensure tomcat-jni.jar is not required by catalina.jar
---
 java/org/apache/catalina/connector/Connector.java | 18 +++++++++++++++++-
 webapps/docs/changelog.xml                        |  5 +++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/connector/Connector.java 
b/java/org/apache/catalina/connector/Connector.java
index 2d41b5ff03..af361f0b22 100644
--- a/java/org/apache/catalina/connector/Connector.java
+++ b/java/org/apache/catalina/connector/Connector.java
@@ -60,6 +60,22 @@ public class Connector extends LifecycleMBeanBase {
 
     public static final String INTERNAL_EXECUTOR_NAME = "Internal";
 
+    private static final boolean aprStatusPresent;
+
+    static {
+        /*
+         * The AprStatus class has to be in the org.apache.tomcat.jni package 
so it can be referenced by the OpenSSL
+         * clean-up code to avoid a race condition on shutdown between the 
AprLifecycleListener shutting down the Tomcat
+         * Native library along with any remaining open connections and the 
OpenSSL clean-up code shutting down an
+         * individual connection that can trigger a JVM crash.
+         *
+         * In some deployment scenarios AprStatus is not present - e.g. 
because tomcat-jni.jar is not present. To avoid
+         * a CNFE in this class on Connector initialisation when AprStatus is 
not present - and ugly work-arounds that
+         * try loading the class and catching the exception - use 
getResource() to see if AprStatus is present.
+         */
+        aprStatusPresent =
+                
(Connector.class.getClassLoader().getResource("org/apache/tomcat/jni/AprStatus.class")
 != null);
+    }
 
     // ------------------------------------------------------------ Constructor
 
@@ -1060,7 +1076,7 @@ public class Connector extends LifecycleMBeanBase {
                 jsseProtocolHandler
                         
.setSslImplementationName("org.apache.tomcat.util.net.openssl.panama.OpenSSLImplementation");
             }
-        } else if (AprStatus.isAprAvailable() && AprStatus.getUseOpenSSL() &&
+        } else if (aprStatusPresent && AprStatus.isAprAvailable() && 
AprStatus.getUseOpenSSL() &&
                 protocolHandler instanceof AbstractHttp11Protocol<?> 
jsseProtocolHandler) {
             // Use tomcat-native and OpenSSL otherwise, if available
             if (jsseProtocolHandler.isSSLEnabled() && 
jsseProtocolHandler.getSslImplementationName() == null) {
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 22f67cf56e..e1b2bb9011 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -190,6 +190,11 @@
         Add log warnings for additional Host <code>appBase</code> suspicious
         values. (remm)
       </fix>
+      <fix>
+        Remove hard dependency on tomcat-jni.jar for catalina.jar.
+        <code>org.apache.catalina.Connector</code> no longer requires
+        <code>org.apache.tomcat.jni.AprStatus</code> to be present. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">


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

Reply via email to