[tomcat] branch master updated: Compatibility with the 0.2.0 migration tool

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: Compatibility with the 0.2.0 migration tool

remm
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 dc06638  Compatibility with the 0.2.0 migration tool
dc06638 is described below

commit dc0663818a4329b965eeb05f65456379fdccf938
Author: remm <[hidden email]>
AuthorDate: Wed Feb 17 11:36:43 2021 +0100

    Compatibility with the 0.2.0 migration tool
---
 java/org/apache/catalina/loader/WebappLoader.java | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/java/org/apache/catalina/loader/WebappLoader.java b/java/org/apache/catalina/loader/WebappLoader.java
index b262db9..33aad92 100644
--- a/java/org/apache/catalina/loader/WebappLoader.java
+++ b/java/org/apache/catalina/loader/WebappLoader.java
@@ -367,17 +367,19 @@ public class WebappLoader extends LifecycleMBeanBase implements Loader{
             // Set Jakarta class converter
             if (getJakartaConverter() != null) {
                 try {
-                    Class<?> jakartaEnumClass = Class.forName("org.apache.tomcat.jakartaee.EESpecProfile");
-                    Method valueOf = jakartaEnumClass.getMethod("valueOf", String.class);
-                    Object profile = null;
+                    ClassFileTransformer transformer = null;
                     try {
-                        profile = valueOf.invoke(null, getJakartaConverter());
-                    } catch (InvocationTargetException ignored) {
-                        profile = valueOf.invoke(null, "TOMCAT");
+                        Class<?> jakartaEnumClass = Class.forName("org.apache.tomcat.jakartaee.EESpecProfile");
+                        Method valueOf = jakartaEnumClass.getMethod("valueOf", String.class);
+                        Object profile = valueOf.invoke(null, getJakartaConverter());
+                        transformer =
+                                (ClassFileTransformer) Class.forName("org.apache.tomcat.jakartaee.ClassConverter")
+                                .getConstructor(jakartaEnumClass).newInstance(profile);
+                    } catch (InvocationTargetException | NoSuchMethodException ignored) {
+                        // Use default value with no argument constructor
+                        transformer =
+                                (ClassFileTransformer) Class.forName("org.apache.tomcat.jakartaee.ClassConverter").newInstance();
                     }
-                    ClassFileTransformer transformer =
-                            (ClassFileTransformer) Class.forName("org.apache.tomcat.jakartaee.ClassConverter")
-                            .getConstructor(jakartaEnumClass).newInstance(profile);
                     classLoader.addTransformer(transformer);
                 } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
                     log.warn(sm.getString("webappLoader.noJakartaConverter"), e);


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