This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push:
new 55f41d78c7 Avoid runtime dependency on the migration tool unless it is
being used
55f41d78c7 is described below
commit 55f41d78c778a82e315b9980b56ff50e89e3af57
Author: Mark Thomas <[email protected]>
AuthorDate: Mon Nov 14 22:37:54 2022 +0000
Avoid runtime dependency on the migration tool unless it is being used
---
java/org/apache/catalina/loader/WebappLoader.java | 29 ++++++++++++++++-------
webapps/docs/changelog.xml | 5 ++++
2 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/java/org/apache/catalina/loader/WebappLoader.java
b/java/org/apache/catalina/loader/WebappLoader.java
index a8fe3cf806..ae4f58523d 100644
--- a/java/org/apache/catalina/loader/WebappLoader.java
+++ b/java/org/apache/catalina/loader/WebappLoader.java
@@ -367,14 +367,7 @@ public class WebappLoader extends LifecycleMBeanBase
implements Loader{
// Set Jakarta class converter
if (getJakartaConverter() != null) {
- EESpecProfile profile = null;
- try {
- profile = EESpecProfiles.valueOf(getJakartaConverter());
- } catch (IllegalArgumentException ignored) {
- // Use default value
- log.warn(sm.getString("webappLoader.unknownProfile",
getJakartaConverter()));
- }
- classLoader.addTransformer((profile != null) ? new
ClassConverter(profile) : new ClassConverter());
+ MigrationUtil.addJakartaEETransformer(classLoader,
getJakartaConverter());
}
// Configure our repositories
@@ -631,4 +624,24 @@ public class WebappLoader extends LifecycleMBeanBase
implements Loader{
return name.toString();
}
+
+
+ /*
+ * Implemented in a sub-class so EESpecProfile and EESpecProfiles are not
+ * loaded unless a profile is configured. Otherwise, tomcat-embed-core.jar
+ * has a runtime dependency on the migration tool whether it is used or
not.
+ */
+ private static class MigrationUtil {
+
+ public static void addJakartaEETransformer(WebappClassLoaderBase
webappClassLoader, String profileName) {
+ EESpecProfile profile = null;
+ try {
+ profile = EESpecProfiles.valueOf(profileName);
+ } catch (IllegalArgumentException ignored) {
+ // Use default value
+ log.warn(sm.getString("webappLoader.unknownProfile",
profileName));
+ }
+ webappClassLoader.addTransformer((profile != null) ? new
ClassConverter(profile) : new ClassConverter());
+ }
+ }
}
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 2e388f53c1..999965c173 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -114,6 +114,11 @@
<code>HttpServletRequest.getTrailerFields()</code> and with the Servlet
API provided by the Jakarta EE project. (markt)
</fix>
+ <fix>
+ Refactor <code>WebappLoader</code> so it only has a runtime dependency
+ on the migration tool for Jakarta EE if configured to use the converter
+ as classes are loaded. (markt)
+ </fix>
</changelog>
</subsection>
</section>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]