On Mon, Nov 14, 2022 at 11:38 PM <ma...@apache.org> wrote: > > This is an automated email from the ASF dual-hosted git repository. > > markt pushed a commit to branch main > in repository https://gitbox.apache.org/repos/asf/tomcat.git > > > The following commit(s) were added to refs/heads/main by this push: > new dc5cab83ae Avoid runtime dependency on the migration tool unless it > is being used > dc5cab83ae is described below > > commit dc5cab83ae13804152b3d1bab90fafb9582764da > Author: Mark Thomas <ma...@apache.org> > AuthorDate: Mon Nov 14 22:37:54 2022 +0000 > > Avoid runtime dependency on the migration tool unless it is being used
Good idea and nice trick. Rémy > --- > 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 cbf01a7ebb..ddf984a862 100644 > --- a/webapps/docs/changelog.xml > +++ b/webapps/docs/changelog.xml > @@ -152,6 +152,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> > <subsection name="Coyote"> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org > For additional commands, e-mail: dev-h...@tomcat.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org