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

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


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

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

    Fix BZ 64514 - classes missing from bootstrap.jar
    
    Signed-off-by: Raymond Augé <rotty3...@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 931524c..e6beaf0 100644
--- a/build.xml
+++ b/build.xml
@@ -370,6 +370,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 eec8215..d2e8698 100644
--- a/java/org/apache/catalina/Globals.java
+++ b/java/org/apache/catalina/Globals.java
@@ -258,14 +258,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 98f035a..579dc00 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 ff07d1f..07a6e07 100644
--- a/java/org/apache/catalina/startup/Constants.java
+++ b/java/org/apache/catalina/startup/Constants.java
@@ -48,4 +48,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 07d5896..f39beac 100644
--- a/java/org/apache/catalina/startup/Tool.java
+++ b/java/org/apache/catalina/startup/Tool.java
@@ -24,10 +24,8 @@ import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.catalina.Globals;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
-import org.apache.tomcat.util.ExceptionUtils;
 
 
 /**
@@ -89,7 +87,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);
 
 
     /**
@@ -123,7 +121,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);
         }
 
@@ -186,7 +184,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);
         }
@@ -200,7 +198,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);
         }
@@ -216,7 +214,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);
         }
@@ -229,8 +227,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 ee341c2..daaedda 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -123,6 +123,11 @@
       <update>
         Update the OWB module to Apache OpenWebBeans 2.0.17. (remm)
       </update>
+      <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-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to