You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2020/06/15 18:39:16 UTC

[tomcat] branch 8.5.x updated: Fix BZ 64514 - classes missing from bootstrap.jar

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

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


The following commit(s) were added to refs/heads/8.5.x by this push:
     new 6a3ab48  Fix BZ 64514 - classes missing from bootstrap.jar
6a3ab48 is described below

commit 6a3ab48001d136bf794fadc7ca55905b6f98065a
Author: Raymond Augé <ro...@apache.org>
AuthorDate: Thu Jun 11 16:44:24 2020 -0400

    Fix BZ 64514 - classes missing from bootstrap.jar
    
    Signed-off-by: Raymond Augé <ro...@apache.org>
---
 build.xml                                       |  1 +
 java/org/apache/catalina/Globals.java           |  4 ++--
 java/org/apache/catalina/startup/Bootstrap.java | 26 +++++++++++++++++--------
 java/org/apache/catalina/startup/Constants.java | 12 ++++++++++++
 java/org/apache/catalina/startup/Tool.java      | 16 +++++++--------
 webapps/docs/changelog.xml                      |  5 +++++
 6 files changed, 45 insertions(+), 19 deletions(-)

diff --git a/build.xml b/build.xml
index 91929a4..3827617 100644
--- a/build.xml
+++ b/build.xml
@@ -365,6 +365,7 @@
     <include name="org/apache/catalina/startup/CatalinaProperties.*" />
     <include name="org/apache/catalina/startup/ClassLoaderFactory.*" />
     <include name="org/apache/catalina/startup/ClassLoaderFactory$*.*" />
+    <include name="org/apache/catalina/startup/Constants.*" />
     <include name="org/apache/catalina/startup/SafeForkJoinWorkerThreadFactory.*" />
     <include name="org/apache/catalina/startup/SafeForkJoinWorkerThreadFactory$*.*" />
     <include name="org/apache/catalina/startup/Tool.*" />
diff --git a/java/org/apache/catalina/Globals.java b/java/org/apache/catalina/Globals.java
index addbdca..52a9f96 100644
--- a/java/org/apache/catalina/Globals.java
+++ b/java/org/apache/catalina/Globals.java
@@ -274,14 +274,14 @@ public final class Globals {
      * Name of the system property containing
      * the tomcat product installation path
      */
-    public static final String CATALINA_HOME_PROP = "catalina.home";
+    public static final String CATALINA_HOME_PROP = org.apache.catalina.startup.Constants.CATALINA_HOME_PROP;
 
 
     /**
      * Name of the system property containing
      * the tomcat instance installation path
      */
-    public static final String CATALINA_BASE_PROP = "catalina.base";
+    public static final String CATALINA_BASE_PROP = org.apache.catalina.startup.Constants.CATALINA_BASE_PROP;
 
 
     // -------------------------------------------------------- Global constants
diff --git a/java/org/apache/catalina/startup/Bootstrap.java b/java/org/apache/catalina/startup/Bootstrap.java
index fdb5266..f52ceca 100644
--- a/java/org/apache/catalina/startup/Bootstrap.java
+++ b/java/org/apache/catalina/startup/Bootstrap.java
@@ -27,7 +27,6 @@ import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.catalina.Globals;
 import org.apache.catalina.security.SecurityClassLoad;
 import org.apache.catalina.startup.ClassLoaderFactory.Repository;
 import org.apache.catalina.startup.ClassLoaderFactory.RepositoryType;
@@ -66,7 +65,7 @@ public final class Bootstrap {
         String userDir = System.getProperty("user.dir");
 
         // Home first
-        String home = System.getProperty(Globals.CATALINA_HOME_PROP);
+        String home = System.getProperty(Constants.CATALINA_HOME_PROP);
         File homeFile = null;
 
         if (home != null) {
@@ -105,10 +104,10 @@ public final class Bootstrap {
 
         catalinaHomeFile = homeFile;
         System.setProperty(
-                Globals.CATALINA_HOME_PROP, catalinaHomeFile.getPath());
+                Constants.CATALINA_HOME_PROP, catalinaHomeFile.getPath());
 
         // Then base
-        String base = System.getProperty(Globals.CATALINA_BASE_PROP);
+        String base = System.getProperty(Constants.CATALINA_BASE_PROP);
         if (base == null) {
             catalinaBaseFile = catalinaHomeFile;
         } else {
@@ -121,7 +120,7 @@ public final class Bootstrap {
             catalinaBaseFile = baseFile;
         }
         System.setProperty(
-                Globals.CATALINA_BASE_PROP, catalinaBaseFile.getPath());
+                Constants.CATALINA_BASE_PROP, catalinaBaseFile.getPath());
     }
 
     // -------------------------------------------------------------- Variables
@@ -222,9 +221,9 @@ public final class Bootstrap {
                 String replacement;
                 if (propName.length() == 0) {
                     replacement = null;
-                } else if (Globals.CATALINA_HOME_PROP.equals(propName)) {
+                } else if (Constants.CATALINA_HOME_PROP.equals(propName)) {
                     replacement = getCatalinaHome();
-                } else if (Globals.CATALINA_BASE_PROP.equals(propName)) {
+                } else if (Constants.CATALINA_BASE_PROP.equals(propName)) {
                     replacement = getCatalinaBase();
                 } else {
                     replacement = System.getProperty(propName);
@@ -542,16 +541,27 @@ public final class Bootstrap {
 
 
     // Copied from ExceptionUtils since that class is not visible during start
-    private static void handleThrowable(Throwable t) {
+    static void handleThrowable(Throwable t) {
         if (t instanceof ThreadDeath) {
             throw (ThreadDeath) t;
         }
+        if (t instanceof StackOverflowError) {
+            // Swallow silently - it should be recoverable
+            return;
+        }
         if (t instanceof VirtualMachineError) {
             throw (VirtualMachineError) t;
         }
         // All other instances of Throwable will be silently swallowed
     }
 
+    // Copied from ExceptionUtils so that there is no dependency on utils
+    static Throwable unwrapInvocationTargetException(Throwable t) {
+        if (t instanceof InvocationTargetException && t.getCause() != null) {
+            return t.getCause();
+        }
+        return t;
+    }
 
     // Protected for unit testing
     protected static String[] getPaths(String value) {
diff --git a/java/org/apache/catalina/startup/Constants.java b/java/org/apache/catalina/startup/Constants.java
index b0c08fb..fa0bc98 100644
--- a/java/org/apache/catalina/startup/Constants.java
+++ b/java/org/apache/catalina/startup/Constants.java
@@ -47,4 +47,16 @@ public final class Constants {
      * @see Tomcat
      */
     public static final String NoDefaultWebXml = "org/apache/catalina/startup/NO_DEFAULT_XML";
+
+    /**
+     * Name of the system property containing
+     * the tomcat product installation path
+     */
+    public static final String CATALINA_HOME_PROP = "catalina.home";
+
+    /**
+     * Name of the system property containing
+     * the tomcat instance installation path
+     */
+    public static final String CATALINA_BASE_PROP = "catalina.base";
 }
diff --git a/java/org/apache/catalina/startup/Tool.java b/java/org/apache/catalina/startup/Tool.java
index 818dd70..a5a4323 100644
--- a/java/org/apache/catalina/startup/Tool.java
+++ b/java/org/apache/catalina/startup/Tool.java
@@ -23,10 +23,8 @@ import java.io.File;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 
-import org.apache.catalina.Globals;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
-import org.apache.tomcat.util.ExceptionUtils;
 
 
 /**
@@ -88,7 +86,7 @@ public final class Tool {
      * The pathname of our installation base directory.
      */
     private static final String catalinaHome =
-            System.getProperty(Globals.CATALINA_HOME_PROP);
+            System.getProperty(Constants.CATALINA_HOME_PROP);
 
 
     /**
@@ -122,7 +120,7 @@ public final class Tool {
 
         // Verify that "catalina.home" was passed.
         if (catalinaHome == null) {
-            log.error("Must set '" + Globals.CATALINA_HOME_PROP + "' system property");
+            log.error("Must set '" + Constants.CATALINA_HOME_PROP + "' system property");
             System.exit(1);
         }
 
@@ -185,7 +183,7 @@ public final class Tool {
                  packed.toArray(new File[0]),
                  null);
         } catch (Throwable t) {
-            ExceptionUtils.handleThrowable(t);
+            Bootstrap.handleThrowable(t);
             log.error("Class loader creation threw exception", t);
             System.exit(1);
         }
@@ -199,7 +197,7 @@ public final class Tool {
                 log.debug("Loading application class " + className);
             clazz = classLoader.loadClass(className);
         } catch (Throwable t) {
-            ExceptionUtils.handleThrowable(t);
+            Bootstrap.handleThrowable(t);
             log.error("Exception creating instance of " + className, t);
             System.exit(1);
         }
@@ -215,7 +213,7 @@ public final class Tool {
             paramTypes[0] = params.getClass();
             method = clazz.getMethod(methodName, paramTypes);
         } catch (Throwable t) {
-            ExceptionUtils.handleThrowable(t);
+            Bootstrap.handleThrowable(t);
             log.error("Exception locating main() method", t);
             System.exit(1);
         }
@@ -228,8 +226,8 @@ public final class Tool {
             paramValues[0] = params;
             method.invoke(null, paramValues);
         } catch (Throwable t) {
-            t = ExceptionUtils.unwrapInvocationTargetException(t);
-            ExceptionUtils.handleThrowable(t);
+            t = Bootstrap.unwrapInvocationTargetException(t);
+            Bootstrap.handleThrowable(t);
             log.error("Exception calling main() method", t);
             System.exit(1);
         }
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 6ff20e5..2481caf 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -94,6 +94,11 @@
         <code>LOGGING_CONFIG</code> environment variable to avoid using a POSIX
         shell feature that is not available by default on Solaris 10. (markt)
       </fix>
+      <fix>
+        <bug>64514</bug>: Fixes some missing class dependency issus in bootstrap
+        to address packaging/dependency concerns for JPMS and OSGi. Pull request
+        provided by Raymond Augé. (markt)
+      </fix>
     </changelog>
   </subsection>
 </section>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org