From 5c7dd1fcd77c2a688dca52e832a285b03d3afa40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Lalire?= Date: Sun, 21 Nov 2021 09:40:06 +0100 Subject: [PATCH] restart TomEEWebappClassLoader patch --- ...ache.tomee.catalina.TomEEWebappClassLoader | 132 ++---------------- .../catalina/TomEEWebappClassLoader.java | 84 +++++------ 2 files changed, 50 insertions(+), 166 deletions(-) diff --git a/catalina/src/main/config/patch/org.apache.tomee.catalina.TomEEWebappClassLoader b/catalina/src/main/config/patch/org.apache.tomee.catalina.TomEEWebappClassLoader index 238e319..2c23511 100644 --- a/catalina/src/main/config/patch/org.apache.tomee.catalina.TomEEWebappClassLoader +++ b/catalina/src/main/config/patch/org.apache.tomee.catalina.TomEEWebappClassLoader @@ -1,127 +1,11 @@ --- org/apache/tomee/catalina/TomEEWebappClassLoader.java 2021-01-01 00:00:00.000000000 +0000 +++ org/apache/tomee/catalina/TomEEWebappClassLoader.java.new 2021-01-01 00:00:00.000000000 +0000 -@@ -16,6 +16,23 @@ - */ - package org.apache.tomee.catalina; - -+import java.io.File; -+import java.io.IOException; -+import java.io.InputStream; -+import java.net.MalformedURLException; -+import java.net.URL; -+import java.util.ArrayList; -+import java.util.Collection; -+import java.util.Collections; -+import java.util.Enumeration; -+import java.util.HashMap; -+import java.util.HashSet; -+import java.util.Iterator; -+import java.util.LinkedList; -+import java.util.List; -+import java.util.Map; -+import java.util.logging.LogManager; -+ - import org.apache.catalina.Context; - import org.apache.catalina.LifecycleException; - import org.apache.catalina.WebResource; -@@ -29,10 +46,8 @@ - import org.apache.openejb.classloader.ClassLoaderConfigurer; - import org.apache.openejb.classloader.CompositeClassLoaderConfigurer; - import org.apache.openejb.classloader.WebAppEnricher; --import org.apache.openejb.config.NewLoaderLogic; - import org.apache.openejb.config.QuickJarsTxtParser; - import org.apache.openejb.core.ParentClassLoaderFinder; --import org.apache.openejb.loader.Files; - import org.apache.openejb.loader.SystemInstance; - import org.apache.openejb.util.AppFinder; - import org.apache.openejb.util.LogCategory; -@@ -41,23 +56,6 @@ - import org.apache.openejb.util.classloader.URLClassLoaderFirst; - import org.apache.openejb.util.reflection.Reflections; - --import java.io.File; --import java.io.IOException; --import java.io.InputStream; --import java.net.MalformedURLException; --import java.net.URL; --import java.util.ArrayList; --import java.util.Collection; --import java.util.Collections; --import java.util.Enumeration; --import java.util.HashMap; --import java.util.HashSet; --import java.util.Iterator; --import java.util.LinkedList; --import java.util.List; --import java.util.Map; --import java.util.logging.LogManager; -- - // TODO: rework it - // constraint: be able to use EM in web components (contextDestroyed() listener for instance) and opposite (link TWAB/Assembler) - // issue: StandardRoot is not lazy stopped -@@ -449,26 +447,26 @@ - - if ("META-INF/services/javax.servlet.ServletContainerInitializer".equals(name)) { - final Collection list = new ArrayList<>(Collections.list(super.getResources(name))); -- final Iterator it = list.iterator(); -- while (it.hasNext()) { -- final URL next = it.next(); -- final File file = Files.toFile(next); -- if (!file.isFile() && NewLoaderLogic.skip(next)) { -- it.remove(); -- } -- } -+ // final Iterator it = list.iterator(); -+ // while (it.hasNext()) { -+ // final URL next = it.next(); -+ // final File file = Files.toFile(next); -+ // if (!file.isFile() && NewLoaderLogic.skip(next)) { -+ // it.remove(); -+ // } -+ // } - return Collections.enumeration(list); - } - if ("META-INF/services/javax.websocket.ContainerProvider".equals(name)) { - final Collection list = new ArrayList<>(Collections.list(super.getResources(name))); -- final Iterator it = list.iterator(); -- while (it.hasNext()) { -- final URL next = it.next(); -- final File file = Files.toFile(next); -- if (!file.isFile() && NewLoaderLogic.skip(next)) { -- it.remove(); -- } -- } -+ // final Iterator it = list.iterator(); -+ // while (it.hasNext()) { -+ // final URL next = it.next(); -+ // final File file = Files.toFile(next); -+ // if (!file.isFile() && NewLoaderLogic.skip(next)) { -+ // it.remove(); -+ // } -+ // } - return Collections.enumeration(list); - } - if ("META-INF/faces-config.xml".equals(name)) { // mojarra workaround -@@ -477,13 +475,15 @@ - Thread.currentThread().getContextClassLoader(), AppFinder.WebBeansContextTransformer.INSTANCE) == null - && Boolean.parseBoolean(SystemInstance.get().getProperty("tomee.jsf.ignore-owb", "true"))) { - final Collection list = new HashSet<>(Collections.list(super.getResources(name))); -- final Iterator it = list.iterator(); -- while (it.hasNext()) { -- final String fileName = Files.toFile(it.next()).getName(); +@@ -480,7 +480,7 @@ + final Iterator it = list.iterator(); + while (it.hasNext()) { + final String fileName = Files.toFile(it.next()).getName(); - if (fileName.startsWith("openwebbeans-"/*jsf|el22*/) && fileName.endsWith(".jar")) { -- it.remove(); -- } -- } -+ // final Iterator it = list.iterator(); -+ // while (it.hasNext()) { -+ // final String fileName = -+ // Files.toFile(it.next()).getName(); -+ // if (fileName.startsWith("openwebbeans-"/*jsf|el22*/) && -+ // fileName.endsWith(".jar")) { -+ // it.remove(); -+ // } -+ // } - return Collections.enumeration(list); - } - } catch (final Throwable th) { ++ if (fileName.startsWith("openwebbeans-"/*jsf|el22*/) && fileName.endsWith(".jar")) { + it.remove(); + } + } diff --git a/catalina/src/main/java/org/apache/tomee/catalina/TomEEWebappClassLoader.java b/catalina/src/main/java/org/apache/tomee/catalina/TomEEWebappClassLoader.java index de007a7..1a1208a 100644 --- a/catalina/src/main/java/org/apache/tomee/catalina/TomEEWebappClassLoader.java +++ b/catalina/src/main/java/org/apache/tomee/catalina/TomEEWebappClassLoader.java @@ -16,23 +16,6 @@ */ package org.apache.tomee.catalina; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.logging.LogManager; - import org.apache.catalina.Context; import org.apache.catalina.LifecycleException; import org.apache.catalina.WebResource; @@ -46,8 +29,10 @@ import org.apache.openejb.OpenEJB; import org.apache.openejb.classloader.ClassLoaderConfigurer; import org.apache.openejb.classloader.CompositeClassLoaderConfigurer; import org.apache.openejb.classloader.WebAppEnricher; +import org.apache.openejb.config.NewLoaderLogic; import org.apache.openejb.config.QuickJarsTxtParser; import org.apache.openejb.core.ParentClassLoaderFinder; +import org.apache.openejb.loader.Files; import org.apache.openejb.loader.SystemInstance; import org.apache.openejb.util.AppFinder; import org.apache.openejb.util.LogCategory; @@ -56,6 +41,23 @@ import org.apache.openejb.util.URLs; import org.apache.openejb.util.classloader.URLClassLoaderFirst; import org.apache.openejb.util.reflection.Reflections; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.logging.LogManager; + // TODO: rework it // constraint: be able to use EM in web components (contextDestroyed() listener for instance) and opposite (link TWAB/Assembler) // issue: StandardRoot is not lazy stopped @@ -447,26 +449,26 @@ public class TomEEWebappClassLoader extends ParallelWebappClassLoader { if ("META-INF/services/javax.servlet.ServletContainerInitializer".equals(name)) { final Collection list = new ArrayList<>(Collections.list(super.getResources(name))); - // final Iterator it = list.iterator(); - // while (it.hasNext()) { - // final URL next = it.next(); - // final File file = Files.toFile(next); - // if (!file.isFile() && NewLoaderLogic.skip(next)) { - // it.remove(); - // } - // } + final Iterator it = list.iterator(); + while (it.hasNext()) { + final URL next = it.next(); + final File file = Files.toFile(next); + if (!file.isFile() && NewLoaderLogic.skip(next)) { + it.remove(); + } + } return Collections.enumeration(list); } if ("META-INF/services/javax.websocket.ContainerProvider".equals(name)) { final Collection list = new ArrayList<>(Collections.list(super.getResources(name))); - // final Iterator it = list.iterator(); - // while (it.hasNext()) { - // final URL next = it.next(); - // final File file = Files.toFile(next); - // if (!file.isFile() && NewLoaderLogic.skip(next)) { - // it.remove(); - // } - // } + final Iterator it = list.iterator(); + while (it.hasNext()) { + final URL next = it.next(); + final File file = Files.toFile(next); + if (!file.isFile() && NewLoaderLogic.skip(next)) { + it.remove(); + } + } return Collections.enumeration(list); } if ("META-INF/faces-config.xml".equals(name)) { // mojarra workaround @@ -475,15 +477,13 @@ public class TomEEWebappClassLoader extends ParallelWebappClassLoader { Thread.currentThread().getContextClassLoader(), AppFinder.WebBeansContextTransformer.INSTANCE) == null && Boolean.parseBoolean(SystemInstance.get().getProperty("tomee.jsf.ignore-owb", "true"))) { final Collection list = new HashSet<>(Collections.list(super.getResources(name))); - // final Iterator it = list.iterator(); - // while (it.hasNext()) { - // final String fileName = - // Files.toFile(it.next()).getName(); - // if (fileName.startsWith("openwebbeans-"/*jsf|el22*/) && - // fileName.endsWith(".jar")) { - // it.remove(); - // } - // } + final Iterator it = list.iterator(); + while (it.hasNext()) { + final String fileName = Files.toFile(it.next()).getName(); + if (fileName.startsWith("openwebbeans-"/*jsf|el22*/) && fileName.endsWith(".jar")) { + it.remove(); + } + } return Collections.enumeration(list); } } catch (final Throwable th) { -- GitLab