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

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


The following commit(s) were added to refs/heads/11.0.x by this push:
     new b42fc1200b Only try and load the native library from CATALINA_HOME 
when it is set
b42fc1200b is described below

commit b42fc1200b8b5fbfebde2fe9fd95b3c85306b6e2
Author: Mark Thomas <[email protected]>
AuthorDate: Wed Sep 2 07:47:06 2026 +0100

    Only try and load the native library from CATALINA_HOME when it is set
---
 java/org/apache/tomcat/jni/Library.java | 37 ++++++++++++++++++---------------
 webapps/docs/changelog.xml              |  4 ++++
 2 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/java/org/apache/tomcat/jni/Library.java 
b/java/org/apache/tomcat/jni/Library.java
index ed4909cc92..0b62b0bb96 100644
--- a/java/org/apache/tomcat/jni/Library.java
+++ b/java/org/apache/tomcat/jni/Library.java
@@ -35,26 +35,29 @@ public final class Library {
     private Library() throws Exception {
         boolean loaded = false;
         StringBuilder err = new StringBuilder();
-        File binLib = new File(System.getProperty(CATALINA_HOME_PROP), "bin");
-        for (int i = 0; i < NAMES.length; i++) {
-            File library = new File(binLib, System.mapLibraryName(NAMES[i]));
-            try {
-                System.load(library.getAbsolutePath());
-                loaded = true;
-            } catch (VirtualMachineError t) {
-                throw t;
-            } catch (Throwable t) {
-                if (library.exists()) {
-                    // File exists but failed to load
+        String catalinaHome = System.getProperty(CATALINA_HOME_PROP);
+        if (catalinaHome != null) {
+            File binLib = new File(catalinaHome, "bin");
+            for (int i = 0; i < NAMES.length; i++) {
+                File library = new File(binLib, 
System.mapLibraryName(NAMES[i]));
+                try {
+                    System.load(library.getAbsolutePath());
+                    loaded = true;
+                } catch (VirtualMachineError t) {
                     throw t;
+                } catch (Throwable t) {
+                    if (library.exists()) {
+                        // File exists but failed to load
+                        throw t;
+                    }
+                    if (i > 0) {
+                        err.append(", ");
+                    }
+                    err.append(t.getMessage());
                 }
-                if (i > 0) {
-                    err.append(", ");
+                if (loaded) {
+                    break;
                 }
-                err.append(t.getMessage());
-            }
-            if (loaded) {
-                break;
             }
         }
         if (!loaded) {
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 318530f458..6b292c1a14 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -198,6 +198,10 @@
         Avoid HTTP/2 exceptions with invalid <code>content-length</code>
         values. (remm)
       </fix>
+      <fix>
+        Only try and load the native library from the 
<code>CATALINA_HOME</code>
+        system property when the property is set. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">


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

Reply via email to