import tomcat-9.0.62-11.el9

c9-beta imports/c9-beta/tomcat-9.0.62-11.el9
CentOS Sources 2 years ago committed by MSVSphere Packaging Team
commit ca71aba683

1
.gitignore vendored

@ -0,0 +1 @@
SOURCES/apache-tomcat-9.0.62-src.tar.gz

@ -0,0 +1 @@
c7256fcf1c253b5f291cc4754ca26ad6e9e8b268 SOURCES/apache-tomcat-9.0.62-src.tar.gz

@ -0,0 +1,8 @@
diff -up ./java/org/apache/tomcat/util/modeler/mbeans-descriptors.dtd.orig ./java/org/apache/tomcat/util/modeler/mbeans-descriptors.dtd
--- ./java/org/apache/tomcat/util/modeler/mbeans-descriptors.dtd.orig 2023-02-07 14:11:25.294179017 -0500
+++ ./java/org/apache/tomcat/util/modeler/mbeans-descriptors.dtd 2023-02-07 14:11:28.629196705 -0500
@@ -1,4 +1,3 @@
-<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with

@ -0,0 +1,7 @@
# Add the JAVA 9 specific start-up parameters required by Tomcat
JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens=java.base/java.lang=ALL-UNNAMED"
JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens=java.base/java.io=ALL-UNNAMED"
JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens=java.base/java.util=ALL-UNNAMED"
JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens=java.base/java.util.concurrent=ALL-UNNAMED"
JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED"
export JDK_JAVA_OPTIONS

@ -0,0 +1,200 @@
diff -up ./build.xml.orig ./build.xml
--- build.xml.orig 2021-07-07 10:53:55.493742841 +0800
+++ build.xml 2021-07-07 11:09:43.107968515 +0800
@@ -1020,7 +1020,7 @@
filesDir="${tomcat.classes}"
filesId="files.annotations-api"
manifest="${tomcat.manifests}/annotations-api.jar.manifest"
- addOSGi="true" />
+ addOSGi="false" />
<!-- Servlet Implementation JAR File -->
<jarIt jarfile="${servlet-api.jar}"
@@ -1029,41 +1029,41 @@
manifest="${tomcat.manifests}/servlet-api.jar.manifest"
notice="${tomcat.manifests}/servlet-api.jar.notice"
license="${tomcat.manifests}/servlet-api.jar.license"
- addOSGi="true" />
+ addOSGi="false" />
<!-- EL Implementation JAR File -->
<jarIt jarfile="${el-api.jar}"
filesDir="${tomcat.classes}"
filesId="files.el-api"
manifest="${tomcat.manifests}/el-api.jar.manifest"
- addOSGi="true" />
+ addOSGi="false" />
<!-- JSP Implementation JAR File -->
<jarIt jarfile="${jsp-api.jar}"
filesDir="${tomcat.classes}"
filesId="files.jsp-api"
manifest="${tomcat.manifests}/jsp-api.jar.manifest"
- addOSGi="true" />
+ addOSGi="false" />
<!-- WebSocket API JAR File -->
<jarIt jarfile="${websocket-api.jar}"
filesDir="${tomcat.classes}"
filesId="files.websocket-api"
manifest="${tomcat.manifests}/websocket-api.jar.manifest"
- addOSGi="true" />
+ addOSGi="false" />
<!-- JASPIC API JAR File -->
<jarIt jarfile="${jaspic-api.jar}"
filesDir="${tomcat.classes}"
filesId="files.jaspic-api"
manifest="${tomcat.manifests}/jaspic-api.jar.manifest"
- addOSGi="true" />
+ addOSGi="false" />
<!-- Tomcat-juli JAR File -->
<jarIt jarfile="${tomcat-juli.jar}"
filesDir="${tomcat.classes}"
filesId="files.tomcat-juli"
- addOSGi="true" />
+ addOSGi="false" />
<!-- Bootstrap JAR File -->
<jarIt jarfile="${bootstrap.jar}"
@@ -1075,61 +1075,61 @@
<jarIt jarfile="${tomcat-util.jar}"
filesDir="${tomcat.classes}"
filesId="files.tomcat-util"
- addOSGi="true" />
+ addOSGi="false" />
<!-- Tomcat API JAR File -->
<jarIt jarfile="${tomcat-api.jar}"
filesDir="${tomcat.classes}"
filesId="files.tomcat-api"
- addOSGi="true" />
+ addOSGi="false" />
<!-- Tomcat Util Scan JAR File -->
<jarIt jarfile="${tomcat-util-scan.jar}"
filesDir="${tomcat.classes}"
filesId="files.tomcat-util-scan"
- addOSGi="true" />
+ addOSGi="false" />
<jarIt jarfile="${tomcat-jni.jar}"
filesDir="${tomcat.classes}"
filesId="files.tomcat-jni"
- addOSGi="true" />
+ addOSGi="false" />
<!-- Protocol handlers - Coyote -->
<jarIt jarfile="${tomcat-coyote.jar}"
filesDir="${tomcat.classes}"
filesId="files.tomcat-coyote"
- addOSGi="true" />
+ addOSGi="false" />
<!-- WebSocket implementation JAR File -->
<jarIt jarfile="${tomcat-websocket.jar}"
filesDir="${tomcat.classes}"
filesId="files.tomcat-websocket"
meta-inf="${tomcat.manifests}/tomcat-websocket.jar"
- addOSGi="true" />
+ addOSGi="false" />
<!-- Catalina GroupCom/Tribes JAR File -->
<jarIt jarfile="${catalina-tribes.jar}"
filesDir="${tomcat.classes}"
filesId="files.catalina-tribes"
- addOSGi="true" />
+ addOSGi="false" />
<!-- Catalina Main JAR File -->
<jarIt jarfile="${catalina.jar}"
filesDir="${tomcat.classes}"
filesId="files.catalina"
- addOSGi="true" />
+ addOSGi="false" />
<!-- Catalina Cluster/HA JAR File -->
<jarIt jarfile="${catalina-ha.jar}"
filesDir="${tomcat.classes}"
filesId="files.catalina-ha"
- addOSGi="true" />
+ addOSGi="false" />
<!-- Server-Side Includes (SSI) -->
<jarIt jarfile="${catalina-ssi.jar}"
filesDir="${tomcat.classes}"
filesId="files.catalina-ssi"
- addOSGi="true" />
+ addOSGi="false" />
<!-- Catalina Ant Tasks JAR File -->
<jarIt jarfile="${catalina-ant.jar}"
@@ -1140,27 +1140,27 @@
<jarIt jarfile="${catalina-storeconfig.jar}"
filesDir="${tomcat.classes}"
filesId="files.catalina-storeconfig"
- addOSGi="true" />
+ addOSGi="false" />
<!-- Jasper EL Implementation JAR File -->
<jarIt jarfile="${jasper-el.jar}"
filesDir="${tomcat.classes}"
filesId="files.jasper-el"
meta-inf="${tomcat.manifests}/jasper-el.jar"
- addOSGi="true" />
+ addOSGi="false" />
<!-- Jasper Implementation JAR File -->
<jarIt jarfile="${jasper.jar}"
filesDir="${tomcat.classes}"
filesId="files.jasper"
meta-inf="${tomcat.manifests}/jasper.jar"
- addOSGi="true" />
+ addOSGi="false" />
<!-- Re-packaged Apache Commons DBCP 2-->
<jarIt jarfile="${tomcat-dbcp.jar}"
filesDir="${tomcat.classes}"
filesId="files.tomcat-dbcp"
- addOSGi="true" />
+ addOSGi="false" />
<!-- i18n JARs -->
<jar jarfile="${tomcat.build}/lib/tomcat-i18n-cs.jar"
@@ -1620,7 +1620,7 @@
filesId="files.tomcat-embed-core"
notice="${tomcat.manifests}/servlet-api.jar.notice"
license="${tomcat.manifests}/servlet-api.jar.license"
- addOSGi="true"
+ addOSGi="false"
addGraal="true"
graalPrefix="org.apache.tomcat.embed/tomcat-embed-core"
graalFiles="res/graal/tomcat-embed-core/native-image"
@@ -1628,7 +1628,7 @@
<jarIt jarfile="${tomcat-embed-el.jar}"
filesDir="${tomcat.classes}"
filesId="files.tomcat-embed-el"
- addOSGi="true"
+ addOSGi="false"
addGraal="true"
graalPrefix="org.apache.tomcat.embed/tomcat-embed-el"
graalFiles="res/graal/tomcat-embed-el/native-image"
@@ -1637,7 +1637,7 @@
filesDir="${tomcat.classes}"
filesId="files.tomcat-embed-jasper"
meta-inf="${tomcat.manifests}/jasper.jar"
- addOSGi="true"
+ addOSGi="false"
addGraal="true"
graalPrefix="org.apache.tomcat.embed/tomcat-embed-jasper"
graalFiles="res/graal/tomcat-embed-jasper/native-image"
@@ -1646,7 +1646,7 @@
filesDir="${tomcat.classes}"
filesId="files.tomcat-embed-websocket"
meta-inf="${tomcat.manifests}/tomcat-websocket.jar"
- addOSGi="true"
+ addOSGi="false"
addGraal="true"
graalPrefix="org.apache.tomcat.embed/tomcat-embed-websocket"
graalFiles="res/graal/tomcat-embed-websocket/native-image"

@ -0,0 +1,24 @@
diff -up ./java/org/apache/jasper/compiler/JDTCompiler.java ./java/org/apache/jasper/compiler/JDTCompiler.java
index 2e361f2..277d8f4 100644
--- java/org/apache/jasper/compiler/JDTCompiler.java
+++ java/org/apache/jasper/compiler/JDTCompiler.java
@@ -310,7 +310,7 @@ public class JDTCompiler extends org.apache.jasper.compiler.Compiler {
} else if(opt.equals("15")) {
settings.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_15);
} else if(opt.equals("16")) {
- settings.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_16);
+ settings.put(CompilerOptions.OPTION_Source, "16");
} else if(opt.equals("17")) {
// Constant not available in latest ECJ version that runs on
// Java 8.
@@ -377,8 +377,8 @@ public class JDTCompiler extends org.apache.jasper.compiler.Compiler {
settings.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_15);
settings.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_15);
} else if(opt.equals("16")) {
- settings.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_16);
- settings.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_16);
+ settings.put(CompilerOptions.OPTION_TargetPlatform, "16");
+ settings.put(CompilerOptions.OPTION_Compliance, "16");
} else if(opt.equals("17")) {
// Constant not available in latest ECJ version that runs on
// Java 8.

@ -0,0 +1,10 @@
--- build.xml.orig 2023-01-19 10:39:11.163687508 +0800
+++ build.xml 2023-01-19 10:44:42.960604444 +0800
@@ -213,6 +213,7 @@
<!-- Classpaths -->
<path id="compile.classpath">
<pathelement location="${bnd.jar}"/>
+ <pathelement location="${bnd-annotation.jar}"/>
<pathelement location="${jdt.jar}"/>
<pathelement location="${jaxrpc-lib.jar}"/>
<pathelement location="${wsdl4j-lib.jar}"/>

@ -0,0 +1,9 @@
--- res/META-INF/bootstrap.jar.manifest.orig 2010-04-06 10:11:09.000000000 -0600
+++ res/META-INF/bootstrap.jar.manifest 2010-04-06 10:45:56.000000000 -0600
@@ -1,6 +1,5 @@
Manifest-Version: 1.0
Main-Class: org.apache.catalina.startup.Bootstrap
-Class-Path: commons-daemon.jar
Specification-Title: Apache Tomcat Bootstrap
Specification-Version: @VERSION_MAJOR_MINOR@
Specification-Vendor: Apache Software Foundation

@ -0,0 +1,25 @@
--- conf/catalina.policy.orig 2022-11-04 16:17:41.227506990 +0800
+++ conf/catalina.policy 2022-11-04 16:21:51.393351415 +0800
@@ -56,6 +56,15 @@ grant codeBase "file:${java.home}/lib/ex
// permission java.security.AllPermission;
//};
+// ========== RHEL SPECIFIC CODE PERMISSIONS =======================================
+
+
+// Allowing everything in /usr/share/java allows too many unknowns to be permitted
+// Specifying the individual jars that tomcat needs to function with the security manager
+// is the safest way forward.
+grant codeBase "file:/usr/share/java/ecj/ecj.jar" {
+ permission java.security.AllPermission;
+};
// ========== CATALINA CODE PERMISSIONS =======================================
@@ -261,4 +270,4 @@ grant codeBase "file:${catalina.home}/we
//
// The permissions granted to a specific JAR
// grant codeBase "war:file:${catalina.base}/webapps/examples.war*/WEB-INF/lib/foo.jar" {
-// };
\ No newline at end of file
+// };

@ -0,0 +1,45 @@
#!/bin/sh
#
# tomcat-digest script
# JPackage Project <http://www.jpackage.org/>
# Source functions library
if [ -f /usr/share/java-utils/java-functions ] ; then
. /usr/share/java-utils/java-functions
else
echo "Can't find functions library, aborting"
exit 1
fi
# Get the tomcat config (use this for environment specific settings)
if [ -z "${TOMCAT_CFG}" ]; then
TOMCAT_CFG="/etc/tomcat/tomcat.conf"
fi
if [ -r "$TOMCAT_CFG" ]; then
. $TOMCAT_CFG
fi
set_javacmd
# CLASSPATH munging
if [ -n "$JSSE_HOME" ]; then
CLASSPATH="${CLASSPATH}:$(build-classpath jcert jnet jsse 2>/dev/null)"
fi
CLASSPATH="${CLASSPATH}:${CATALINA_HOME}/bin/bootstrap.jar"
CLASSPATH="${CLASSPATH}:${CATALINA_HOME}/bin/tomcat-juli.jar"
export CLASSPATH
# Configuration
MAIN_CLASS="org.apache.catalina.startup.Tool"
BASE_FLAGS="-Dcatalina.home=\"$CATALINA_HOME\""
BASE_OPTIONS=""
BASE_JARS="commons-daemon tomcat/catalina servlet tomcat/tomcat-util tomcat/tomcat-coyote tomcat/tomcat-api tomcat/tomcat-util-scan"
# Set parameters
set_classpath $BASE_JARS
set_flags $BASE_FLAGS
set_options $BASE_OPTIONS
# Let's start
run -server org.apache.catalina.realm.RealmBase "$@"

@ -0,0 +1,345 @@
diff --git a/java/org/apache/catalina/loader/WebappClassLoaderBase.java b/java/org/apache/catalina/loader/WebappClassLoaderBase.java
index 8746b6b..dc878c6 100644
--- a/java/org/apache/catalina/loader/WebappClassLoaderBase.java
+++ b/java/org/apache/catalina/loader/WebappClassLoaderBase.java
@@ -1820,41 +1820,13 @@ public abstract class WebappClassLoaderBase extends URLClassLoader
// shutting down the executor
boolean usingExecutor = false;
try {
-
- // Runnable wrapped by Thread
- // "target" in Sun/Oracle JDK
- // "runnable" in IBM JDK
- // "action" in Apache Harmony
- Object target = null;
- for (String fieldName : new String[] { "target", "runnable", "action" }) {
- try {
- Field targetField = thread.getClass().getDeclaredField(fieldName);
- targetField.setAccessible(true);
- target = targetField.get(thread);
- break;
- } catch (NoSuchFieldException nfe) {
- continue;
- }
- }
-
- // "java.util.concurrent" code is in public domain,
- // so all implementations are similar including our
- // internal fork.
- if (target != null && target.getClass().getCanonicalName() != null &&
- (target.getClass().getCanonicalName().equals(
- "org.apache.tomcat.util.threads.ThreadPoolExecutor.Worker") ||
- target.getClass().getCanonicalName().equals(
- "java.util.concurrent.ThreadPoolExecutor.Worker"))) {
- Field executorField = target.getClass().getDeclaredField("this$0");
- executorField.setAccessible(true);
- Object executor = executorField.get(target);
- if (executor instanceof ThreadPoolExecutor) {
- ((ThreadPoolExecutor) executor).shutdownNow();
- usingExecutor = true;
- } else if (executor instanceof java.util.concurrent.ThreadPoolExecutor) {
- ((java.util.concurrent.ThreadPoolExecutor) executor).shutdownNow();
- usingExecutor = true;
- }
+ Object executor = JreCompat.getInstance().getExecutor(thread);
+ if (executor instanceof ThreadPoolExecutor) {
+ ((ThreadPoolExecutor) executor).shutdownNow();
+ usingExecutor = true;
+ } else if (executor instanceof java.util.concurrent.ThreadPoolExecutor) {
+ ((java.util.concurrent.ThreadPoolExecutor) executor).shutdownNow();
+ usingExecutor = true;
}
} catch (NoSuchFieldException | IllegalAccessException | RuntimeException e) {
// InaccessibleObjectException is only available in Java 9+,
@@ -2306,6 +2278,12 @@ public abstract class WebappClassLoaderBase extends URLClassLoader
private void clearReferencesObjectStreamClassCaches() {
+ if (JreCompat.isJre19Available()) {
+ // The memory leak this fixes has been fixed in Java 19 onwards,
+ // 17.0.4 onwards and 11.0.16 onwards
+ // See https://bugs.openjdk.java.net/browse/JDK-8277072
+ return;
+ }
try {
Class<?> clazz = Class.forName("java.io.ObjectStreamClass$Caches");
clearCache(clazz, "localDescs");
@@ -2333,14 +2311,19 @@ public abstract class WebappClassLoaderBase extends URLClassLoader
throws ReflectiveOperationException, SecurityException, ClassCastException {
Field f = target.getDeclaredField(mapName);
f.setAccessible(true);
- Map<?,?> map = (Map<?,?>) f.get(null);
- Iterator<?> keys = map.keySet().iterator();
- while (keys.hasNext()) {
- Object key = keys.next();
- if (key instanceof Reference) {
- Object clazz = ((Reference<?>) key).get();
- if (loadedByThisOrChild(clazz)) {
- keys.remove();
+ Object map = f.get(null);
+ // Avoid trying to clear references if Tomcat is running on a JRE that
+ // includes the fix for this memory leak
+ // See https://bugs.openjdk.java.net/browse/JDK-8277072
+ if (map instanceof Map<?,?>) {
+ Iterator<?> keys = ((Map<?,?>) map).keySet().iterator();
+ while (keys.hasNext()) {
+ Object key = keys.next();
+ if (key instanceof Reference) {
+ Object clazz = ((Reference<?>) key).get();
+ if (loadedByThisOrChild(clazz)) {
+ keys.remove();
+ }
}
}
}
diff --git a/java/org/apache/tomcat/util/compat/JreCompat.java b/java/org/apache/tomcat/util/compat/JreCompat.java
index 62df145..e5df728 100644
--- a/java/org/apache/tomcat/util/compat/JreCompat.java
+++ b/java/org/apache/tomcat/util/compat/JreCompat.java
@@ -19,6 +19,7 @@ package org.apache.tomcat.util.compat;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.SocketAddress;
@@ -45,6 +46,7 @@ public class JreCompat {
private static final JreCompat instance;
private static final boolean graalAvailable;
+ private static final boolean jre19Available;
private static final boolean jre16Available;
private static final boolean jre11Available;
private static final boolean jre9Available;
@@ -67,18 +69,26 @@ public class JreCompat {
// This is Tomcat 9 with a minimum Java version of Java 8.
// Look for the highest supported JVM first
- if (Jre16Compat.isSupported()) {
+ if (Jre19Compat.isSupported()) {
+ instance = new Jre19Compat();
+ jre9Available = true;
+ jre16Available = true;
+ jre19Available = true;
+ } else if (Jre16Compat.isSupported()) {
instance = new Jre16Compat();
jre9Available = true;
jre16Available = true;
+ jre19Available = false;
} else if (Jre9Compat.isSupported()) {
instance = new Jre9Compat();
jre9Available = true;
jre16Available = false;
+ jre19Available = false;
} else {
instance = new JreCompat();
jre9Available = false;
jre16Available = false;
+ jre19Available = false;
}
jre11Available = instance.jarFileRuntimeMajorVersion() >= 11;
@@ -124,6 +134,9 @@ public class JreCompat {
return jre16Available;
}
+ public static boolean isJre19Available() {
+ return jre19Available;
+ }
// Java 8 implementation of Java 9 methods
@@ -303,6 +316,8 @@ public class JreCompat {
}
+ // Java 8 implementations of Java 16 methods
+
/**
* Return Unix domain socket address for given path.
* @param path The path
@@ -329,4 +344,63 @@ public class JreCompat {
public SocketChannel openUnixDomainSocketChannel() {
throw new UnsupportedOperationException(sm.getString("jreCompat.noUnixDomainSocket"));
}
+
+
+ // Java 8 implementations of Java 19 methods
+
+ /**
+ * Obtains the executor, if any, used to create the provided thread.
+ *
+ * @param thread The thread to examine
+ *
+ * @return The executor, if any, that created the provided thread
+ *
+ * @throws NoSuchFieldException
+ * If a field used via reflection to obtain the executor cannot
+ * be found
+ * @throws SecurityException
+ * If a security exception occurs while trying to identify the
+ * executor
+ * @throws IllegalArgumentException
+ * If the instance object does not match the class of the field
+ * when obtaining a field value via reflection
+ * @throws IllegalAccessException
+ * If a field is not accessible due to access restrictions
+ */
+ public Object getExecutor(Thread thread)
+ throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
+
+ Object result = null;
+
+ // Runnable wrapped by Thread
+ // "target" in Sun/Oracle JDK
+ // "runnable" in IBM JDK
+ // "action" in Apache Harmony
+ Object target = null;
+ for (String fieldName : new String[] { "target", "runnable", "action" }) {
+ try {
+ Field targetField = thread.getClass().getDeclaredField(fieldName);
+ targetField.setAccessible(true);
+ target = targetField.get(thread);
+ break;
+ } catch (NoSuchFieldException nfe) {
+ continue;
+ }
+ }
+
+ // "java.util.concurrent" code is in public domain,
+ // so all implementations are similar including our
+ // internal fork.
+ if (target != null && target.getClass().getCanonicalName() != null &&
+ (target.getClass().getCanonicalName().equals(
+ "org.apache.tomcat.util.threads.ThreadPoolExecutor.Worker") ||
+ target.getClass().getCanonicalName().equals(
+ "java.util.concurrent.ThreadPoolExecutor.Worker"))) {
+ Field executorField = target.getClass().getDeclaredField("this$0");
+ executorField.setAccessible(true);
+ result = executorField.get(target);
+ }
+
+ return result;
+ }
}
diff --git a/java/org/apache/tomcat/util/compat/LocalStrings.properties b/java/org/apache/tomcat/util/compat/LocalStrings.properties
index 79427da..c4c2f7d 100644
--- a/java/org/apache/tomcat/util/compat/LocalStrings.properties
+++ b/java/org/apache/tomcat/util/compat/LocalStrings.properties
@@ -16,6 +16,8 @@
jre16Compat.javaPre16=Class not found so assuming code is running on a pre-Java 16 JVM
jre16Compat.unexpected=Failed to create references to Java 16 classes and methods
+jre19Compat.javaPre19=Class not found so assuming code is running on a pre-Java 19 JVM
+
jre9Compat.invalidModuleUri=The module URI provided [{0}] could not be converted to a URL for the JarScanner to process
jre9Compat.javaPre9=Class not found so assuming code is running on a pre-Java 9 JVM
jre9Compat.unexpected=Failed to create references to Java 9 classes and methods
diff --git a/webapps/docs/config/context.xml b/webapps/docs/config/context.xml
index d118196..42dfe38 100644
--- a/webapps/docs/config/context.xml
+++ b/webapps/docs/config/context.xml
@@ -769,7 +769,11 @@
therefore requires that the command line option
<code>-XaddExports:java.base/java.io=ALL-UNNAMED</code> is set
when running on Java 9 and above. If not specified, the default value of
- <code>true</code> will be used.</p>
+ <code>true</code> will be used.</p>
+ <p>The memory leak associated with <code>ObjectStreamClass</code> has
+ been fixed in Java 19 onwards, Java 17.0.4 onwards and Java 11.0.16
+ onwards. The check will be disabled when running on a version
+ of Java that contains the fix.</p>
</attribute>
<attribute name="clearReferencesRmiTargets" required="false">
diff --git a/java/org/apache/tomcat/util/compat/Jre19Compat.java b/java/org/apache/tomcat/util/compat/Jre19Compat.java
new file mode 100644
index 0000000000..fb94810b40
--- /dev/null
+++ b/java/org/apache/tomcat/util/compat/Jre19Compat.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomcat.util.compat;
+
+import java.lang.reflect.Field;
+
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.res.StringManager;
+
+public class Jre19Compat extends Jre16Compat {
+
+ private static final Log log = LogFactory.getLog(Jre19Compat.class);
+ private static final StringManager sm = StringManager.getManager(Jre19Compat.class);
+
+ private static final boolean supported;
+
+ static {
+ // Don't need any Java 19 specific classes (yet) so just test for one of
+ // the new ones for now.
+ Class<?> c1 = null;
+ try {
+ c1 = Class.forName("java.lang.WrongThreadException");
+ } catch (ClassNotFoundException cnfe) {
+ // Must be pre-Java 16
+ log.debug(sm.getString("jre19Compat.javaPre19"), cnfe);
+ }
+
+ supported = (c1 != null);
+ }
+
+ static boolean isSupported() {
+ return supported;
+ }
+
+ @Override
+ public Object getExecutor(Thread thread)
+ throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
+
+ Object result = super.getExecutor(thread);
+
+ if (result == null) {
+ Object holder = null;
+ Object task = null;
+ try {
+ Field holderField = thread.getClass().getDeclaredField("holder");
+ holderField.setAccessible(true);
+ holder = holderField.get(thread);
+
+ Field taskField = holder.getClass().getDeclaredField("task");
+ taskField.setAccessible(true);
+ task = taskField.get(holder);
+ } catch (NoSuchFieldException nfe) {
+ return null;
+ }
+
+ if (task!= null && task.getClass().getCanonicalName() != null &&
+ (task.getClass().getCanonicalName().equals(
+ "org.apache.tomcat.util.threads.ThreadPoolExecutor.Worker") ||
+ task.getClass().getCanonicalName().equals(
+ "java.util.concurrent.ThreadPoolExecutor.Worker"))) {
+ Field executorField = task.getClass().getDeclaredField("this$0");
+ executorField.setAccessible(true);
+ result = executorField.get(task);
+ }
+ }
+
+ return result;
+ }
+}

@ -0,0 +1,17 @@
--- conf/tomcat-users.xml~ 2008-01-28 17:41:06.000000000 -0500
+++ conf/tomcat-users.xml 2008-03-07 19:40:07.000000000 -0500
@@ -53,4 +53,14 @@
<user username="both" password="<must-be-changed>" roles="tomcat,role1"/>
<user username="role1" password="<must-be-changed>" roles="role1"/>
-->
+
+<!-- <role rolename="admin"/> -->
+<!-- <role rolename="admin-gui"/> -->
+<!-- <role rolename="admin-script"/> -->
+<!-- <role rolename="manager"/> -->
+<!-- <role rolename="manager-gui"/> -->
+<!-- <role rolename="manager-script"/> -->
+<!-- <role rolename="manager-jmx"/> -->
+<!-- <role rolename="manager-status"/> -->
+<!-- <user name="admin" password="<must-be-changed>" roles="admin,manager,admin-gui,admin-script,manager-gui,manager-script,manager-jmx,manager-status" /> -->
</tomcat-users>

@ -0,0 +1,45 @@
#!/bin/sh
#
# tomcat-digest script
# JPackage Project <http://www.jpackage.org/>
# Source functions library
if [ -f /usr/share/java-utils/java-functions ] ; then
. /usr/share/java-utils/java-functions
else
echo "Can't find functions library, aborting"
exit 1
fi
# Get the tomcat config (use this for environment specific settings)
if [ -z "${TOMCAT_CFG}" ]; then
TOMCAT_CFG="/etc/tomcat/tomcat.conf"
fi
if [ -r "$TOMCAT_CFG" ]; then
. $TOMCAT_CFG
fi
set_javacmd
# CLASSPATH munging
if [ -n "$JSSE_HOME" ]; then
CLASSPATH="${CLASSPATH}:$(build-classpath jcert jnet jsse 2>/dev/null)"
fi
CLASSPATH="${CLASSPATH}:${CATALINA_HOME}/bin/bootstrap.jar"
CLASSPATH="${CLASSPATH}:${CATALINA_HOME}/bin/tomcat-juli.jar"
export CLASSPATH
# Configuration
MAIN_CLASS="org.apache.catalina.startup.Tool"
BASE_OPTIONS=""
BASE_FLAGS="-Dcatalina.home=\"$CATALINA_HOME\""
BASE_JARS="commons-daemon tomcat/catalina servlet tomcat/tomcat-util tomcat/tomcat-coyote tomcat/tomcat-api tomcat/tomcat-util-scan"
# Set parameters
set_classpath $BASE_JARS
set_flags $BASE_FLAGS
set_options $BASE_OPTIONS
# Let's start
run "$@"

@ -0,0 +1,51 @@
# System-wide configuration file for tomcat services
# This will be loaded by systemd as an environment file,
# so please keep the syntax. For shell expansion support
# place your custom files as /etc/tomcat/conf.d/*.conf
#
# There are 2 "classes" of startup behavior in this package.
# The old one, the default service named tomcat.service.
# The new named instances are called tomcat@instance.service.
#
# Use this file to change default values for all services.
# Change the service specific ones to affect only one service.
# For tomcat.service it's /etc/sysconfig/tomcat, for
# tomcat@instance it's /etc/sysconfig/tomcat@instance.
# This variable is used to figure out if config is loaded or not.
TOMCAT_CFG_LOADED="1"
# In new-style instances, if CATALINA_BASE isn't specified, it will
# be constructed by joining TOMCATS_BASE and NAME.
TOMCATS_BASE="/var/lib/tomcats/"
# Where your java installation lives
JAVA_HOME="/usr/lib/jvm/jre"
# Where your tomcat installation lives
CATALINA_HOME="@@@TCHOME@@@"
# System-wide tmp
CATALINA_TMPDIR="/var/cache/tomcat/temp"
# You can pass some parameters to java here if you wish to
#JAVA_OPTS="-Xminf0.1 -Xmaxf0.3"
# Use JAVA_OPTS to set java.library.path for libtcnative.so
#JAVA_OPTS="-Djava.library.path=/usr/lib"
# Set default javax.sql.DataSource factory to apache commons one. See rhbz#1214381
JAVA_OPTS="-Djavax.sql.DataSource.Factory=org.apache.commons.dbcp.BasicDataSourceFactory"
# You can change your tomcat locale here
#LANG="en_US"
# Run tomcat under the Java Security Manager
SECURITY_MANAGER="false"
# SHUTDOWN_WAIT has been deprecated. To change the shutdown wait time, set
# TimeoutStopSec in tomcat.service.
# If you wish to further customize your tomcat environment,
# put your own definitions here
# (i.e. LD_LIBRARY_PATH for some jdbc drivers)

@ -0,0 +1,11 @@
# This is an example config only and is disabled by default
# If you wish to use it, you'll need to update /etc/tomcat/logging.properties
# to prevent catalina*.log from being rotated by Tomcat
@@@TCLOG@@@/catalina*.log {
copytruncate
weekly
rotate 52
compress
missingok
create 0644 tomcat tomcat
}

@ -0,0 +1,20 @@
# Systemd unit file for default tomcat
#
# To create clones of this service:
# DO NOTHING, use tomcat@.service instead.
[Unit]
Description=Apache Tomcat Web Application Container
After=syslog.target network.target
[Service]
Type=simple
EnvironmentFile=/etc/tomcat/tomcat.conf
Environment="NAME="
EnvironmentFile=-/etc/sysconfig/tomcat
ExecStart=/usr/libexec/tomcat/server start
SuccessExitStatus=143
User=tomcat
[Install]
WantedBy=multi-user.target

@ -0,0 +1,11 @@
# Service-specific configuration file for tomcat. This will be sourced by
# systemd for the default service (tomcat.service)
# If you want to customize named instance, make a similar file
# and name it tomcat@instancename.
# You will not need to set this, usually. For default service it equals
# CATALINA_HOME. For named service, it equals ${TOMCATS_BASE}${NAME}
#CATALINA_BASE="@@@TCHOME@@@"
# Please take a look at /etc/tomcat/tomcat.conf to have an idea what you
# can override.

@ -0,0 +1,24 @@
#!/bin/bash
if [ "$1" = "version" ]; then
. /usr/libexec/tomcat/preamble
exec ${JAVACMD} -classpath ${CATALINA_HOME}/lib/catalina.jar \
org.apache.catalina.util.ServerInfo
fi
SRV="tomcat"
if [ -n "$2" ]; then
SRV="tomcat@$2"
fi
if [ "$1" = "start" ]; then
systemctl start ${SRV}.service
elif [ "$1" = "stop" ]; then
systemctl stop ${SRV}.service
elif [ "$1" = "version" ]; then
${JAVACMD} -classpath ${CATALINA_HOME}/lib/catalina.jar \
org.apache.catalina.util.ServerInfo
else
echo "Usage: $0 {start|stop|version} [server-id]"
exit 1
fi

@ -0,0 +1,12 @@
diff -up ./res/bnd/build-defaults.bnd.orig ./res/bnd/build-defaults.bnd
--- ./res/bnd/build-defaults.bnd.orig 2020-07-13 13:47:01.229077747 -0400
+++ ./res/bnd/build-defaults.bnd 2020-07-13 13:47:12.923095618 -0400
@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-Bundle-Version: ${version_cleanup;${version}}
+Bundle-Version: ${version}
Specification-Title: Apache Tomcat
Specification-Version: ${version.major.minor}

@ -0,0 +1,42 @@
#!/bin/bash
if [ -r /usr/share/java-utils/java-functions ]; then
. /usr/share/java-utils/java-functions
else
echo "Can't read Java functions library, aborting"
exit 1
fi
_save_function() {
local ORIG_FUNC=$(declare -f $1)
local NEWNAME_FUNC="$2${ORIG_FUNC#$1}"
eval "$NEWNAME_FUNC"
}
run_jsvc(){
if [ -x /usr/bin/jsvc ]; then
TOMCAT_USER="${TOMCAT_USER:-tomcat}"
JSVC="/usr/bin/jsvc"
JSVC_OPTS="-nodetach -pidfile /var/run/jsvc-tomcat${NAME}.pid -user ${TOMCAT_USER} -outfile ${CATALINA_BASE}/logs/catalina.out -errfile ${CATALINA_BASE}/logs/catalina.out"
if [ "$1" = "stop" ]; then
JSVC_OPTS="${JSVC_OPTS} -stop"
fi
exec "${JSVC}" ${JSVC_OPTS} ${FLAGS} -classpath "${CLASSPATH}" ${OPTIONS} "${MAIN_CLASS}" "${@}"
else
echo "Can't find /usr/bin/jsvc executable"
fi
}
_save_function run run_java
run() {
if [ "${USE_JSVC}" = "true" ] ; then
run_jsvc $@
else
run_java $@
fi
}

@ -0,0 +1,24 @@
# Systemd unit file for tomcat instances.
#
# To create clones of this service:
# 0. systemctl enable tomcat@name.service
# 1. create catalina.base directory structure in
# /var/lib/tomcats/name
# 2. profit.
[Unit]
Description=Apache Tomcat Web Application Container
After=syslog.target network.target
[Service]
Type=simple
EnvironmentFile=/etc/tomcat/tomcat.conf
Environment="NAME=%i"
EnvironmentFile=-/etc/sysconfig/tomcat@%i
ExecStart=/usr/libexec/tomcat/server start
ExecStop=/usr/libexec/tomcat/server stop
SuccessExitStatus=143
User=tomcat
[Install]
WantedBy=multi-user.target

@ -0,0 +1,52 @@
#!/bin/bash
. /usr/libexec/tomcat/functions
# Get the tomcat config (use this for environment specific settings)
if [ -z "${TOMCAT_CFG_LOADED}" ]; then
if [ -z "${TOMCAT_CFG}" ]; then
TOMCAT_CFG="/etc/tomcat/tomcat.conf"
fi
. $TOMCAT_CFG
fi
if [ -d "${TOMCAT_CONFD=/etc/tomcat/conf.d}" ]; then
for file in ${TOMCAT_CONFD}/*.conf ; do
if [ -f "$file" ] ; then
. "$file"
fi
done
fi
if [ -z "$CATALINA_BASE" ]; then
if [ -n "$NAME" ]; then
if [ -z "$TOMCATS_BASE" ]; then
TOMCATS_BASE="/var/lib/tomcats/"
fi
CATALINA_BASE="${TOMCATS_BASE}${NAME}"
else
CATALINA_BASE="${CATALINA_HOME}"
fi
fi
VERBOSE=1
set_javacmd
cd ${CATALINA_HOME}
# CLASSPATH munging
if [ ! -z "$CLASSPATH" ] ; then
CLASSPATH="$CLASSPATH":
fi
if [ -n "$JSSE_HOME" ]; then
CLASSPATH="${CLASSPATH}$(build-classpath jcert jnet jsse 2>/dev/null):"
fi
CLASSPATH="${CLASSPATH}${CATALINA_HOME}/bin/bootstrap.jar"
CLASSPATH="${CLASSPATH}:${CATALINA_HOME}/bin/tomcat-juli.jar"
CLASSPATH="${CLASSPATH}:$(build-classpath commons-daemon 2>/dev/null)"
if [ -z "$LOGGING_PROPERTIES" ] ; then
LOGGING_PROPERTIES="${CATALINA_BASE}/conf/logging.properties"
if [ ! -f "${LOGGING_PROPERTIES}" ] ; then
LOGGING_PROPERTIES="${CATALINA_HOME}/conf/logging.properties"
fi
fi

@ -0,0 +1,25 @@
#!/bin/bash
. /usr/libexec/tomcat/preamble
MAIN_CLASS=org.apache.catalina.startup.Bootstrap
FLAGS="$JAVA_OPTS"
OPTIONS="-Dcatalina.base=$CATALINA_BASE \
-Dcatalina.home=$CATALINA_HOME \
-Djava.endorsed.dirs=$JAVA_ENDORSED_DIRS \
-Djava.io.tmpdir=$CATALINA_TMPDIR \
-Djava.util.logging.config.file=${LOGGING_PROPERTIES} \
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
if [ "$1" = "start" ] ; then
FLAGS="${FLAGS} $CATALINA_OPTS"
if [ "${SECURITY_MANAGER}" = "true" ] ; then
OPTIONS="${OPTIONS} \
-Djava.security.manager \
-Djava.security.policy==${CATALINA_BASE}/conf/catalina.policy"
fi
run start
elif [ "$1" = "stop" ] ; then
run stop
fi

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save