[tomcat] branch master updated: Cleanup code using the new tool release

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[tomcat] branch master updated: Cleanup code using the new tool release

Rémy Maucherat
This is an automated email from the ASF dual-hosted git repository.

remm 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 9747a3a  Cleanup code using the new tool release
9747a3a is described below

commit 9747a3a6334369deb9b5bef1b17b1fe0ce774cdf
Author: remm <[hidden email]>
AuthorDate: Mon May 10 09:13:54 2021 +0200

    Cleanup code using the new tool release
   
    Also log when an unknown profile is specified.
---
 java/org/apache/catalina/loader/LocalStrings.properties |  1 +
 java/org/apache/catalina/loader/WebappLoader.java       | 17 ++++++-----------
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/java/org/apache/catalina/loader/LocalStrings.properties b/java/org/apache/catalina/loader/LocalStrings.properties
index 7c6c976..521c90f 100644
--- a/java/org/apache/catalina/loader/LocalStrings.properties
+++ b/java/org/apache/catalina/loader/LocalStrings.properties
@@ -67,3 +67,4 @@ webappLoader.starting=Starting this Loader
 webappLoader.stopError=Error stopping the loader
 webappLoader.stopping=Stopping this Loader
 webappLoader.unknownClassLoader=Unknown class loader [{0}] of class [{1}]
+webappLoader.unknownProfile=Unknown Jakarta profile [{0}] specified, the default profile will be used instead
diff --git a/java/org/apache/catalina/loader/WebappLoader.java b/java/org/apache/catalina/loader/WebappLoader.java
index a9d5ccc..5015b93 100644
--- a/java/org/apache/catalina/loader/WebappLoader.java
+++ b/java/org/apache/catalina/loader/WebappLoader.java
@@ -21,9 +21,7 @@ import java.beans.PropertyChangeSupport;
 import java.io.File;
 import java.io.FilePermission;
 import java.io.IOException;
-import java.lang.instrument.ClassFileTransformer;
 import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.nio.charset.StandardCharsets;
@@ -367,17 +365,14 @@ public class WebappLoader extends LifecycleMBeanBase implements Loader{
 
             // Set Jakarta class converter
             if (getJakartaConverter() != null) {
-                ClassFileTransformer transformer = null;
+                EESpecProfile profile = null;
                 try {
-                    EESpecProfile profile = EESpecProfile.valueOf(getJakartaConverter());
-                    transformer = ClassConverter.class.getConstructor(EESpecProfile.class).newInstance(profile);
-                    // FIXME: after Migration 0.3
-                    //transformer = new ClassConverter(EESpecProfile.valueOf(getJakartaConverter()));
-                } catch (InvocationTargetException | NoSuchMethodException | IllegalArgumentException ignored) {
-                    // Use default value with no argument constructor
-                    transformer = new ClassConverter();
+                    profile = EESpecProfile.valueOf(getJakartaConverter());
+                } catch (IllegalArgumentException ignored) {
+                    // Use default value
+                    log.warn(sm.getString("webappLoader.unknownProfile", getJakartaConverter()));
                 }
-                classLoader.addTransformer(transformer);
+                classLoader.addTransformer((profile != null) ? new ClassConverter(profile) : new ClassConverter());
             }
 
             // Configure our repositories

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]