Merge remote-tracking branch 'origin/jetty-11.0.x' into jetty-12.0.x

This commit is contained in:
Jan Bartel 2022-10-17 11:36:40 +11:00
commit a3bf740f42
3 changed files with 5 additions and 34 deletions

View File

@ -29,14 +29,6 @@
This file is applied to a Web application before its own WEB_INF/web.xml file This file is applied to a Web application before its own WEB_INF/web.xml file
</description> </description>
<!-- ==================================================================== -->
<!-- Removes static references to beans from javax.el.BeanELResolver to -->
<!-- ensure webapp classloader can be released on undeploy -->
<!-- ==================================================================== -->
<listener>
<listener-class>org.eclipse.jetty.ee8.servlet.listener.ELContextCleaner</listener-class>
</listener>
<!-- ==================================================================== --> <!-- ==================================================================== -->
<!-- Removes static cache of Methods from java.beans.Introspector to --> <!-- Removes static cache of Methods from java.beans.Introspector to -->
<!-- ensure webapp classloader can be released on undeploy --> <!-- ensure webapp classloader can be released on undeploy -->

View File

@ -31,6 +31,7 @@ import org.eclipse.jetty.util.Loader;
* See http://java.net/jira/browse/GLASSFISH-1649 * See http://java.net/jira/browse/GLASSFISH-1649
* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=353095 * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=353095
*/ */
@Deprecated
public class ELContextCleaner implements ServletContextListener public class ELContextCleaner implements ServletContextListener
{ {
// IMPORTANT: This class cannot have a slf4j Logger // IMPORTANT: This class cannot have a slf4j Logger
@ -51,35 +52,21 @@ public class ELContextCleaner implements ServletContextListener
Class<?> beanELResolver = Loader.loadClass("jakarta.el.BeanELResolver"); Class<?> beanELResolver = Loader.loadClass("jakarta.el.BeanELResolver");
//Get a reference via reflection to the properties field which is holding class references //Get a reference via reflection to the properties field which is holding class references
Field field = getField(beanELResolver); Field field = beanELResolver.getDeclaredField("properties");
field.setAccessible(true); field.setAccessible(true);
//Get rid of references //Get rid of references
purgeEntries(sce.getServletContext(), field); purgeEntries(sce.getServletContext(), field);
} }
catch (ClassNotFoundException | NoSuchFieldException e)
catch (ClassNotFoundException e)
{ {
//BeanELResolver not on classpath, ignore //BeanELResolver not on classpath,or has no .properties field, ignore
} }
catch (SecurityException | IllegalArgumentException | IllegalAccessException e) catch (SecurityException | IllegalArgumentException | IllegalAccessException e)
{ {
sce.getServletContext().log("Cannot purge classes from javax.el.BeanELResolver", e); sce.getServletContext().log("Cannot purge classes from jakarta.el.BeanELResolver", e);
} }
catch (NoSuchFieldException e)
{
sce.getServletContext().log("Not cleaning cached beans: no such field javax.el.BeanELResolver.properties");
}
}
protected Field getField(Class<?> beanELResolver)
throws SecurityException, NoSuchFieldException
{
if (beanELResolver == null)
return null;
return beanELResolver.getDeclaredField("properties");
} }
@SuppressWarnings({"rawtypes", "unchecked"}) @SuppressWarnings({"rawtypes", "unchecked"})

View File

@ -29,14 +29,6 @@
This file is applied to a Web application before its own WEB_INF/web.xml file This file is applied to a Web application before its own WEB_INF/web.xml file
</description> </description>
<!-- ==================================================================== -->
<!-- Removes static references to beans from javax.el.BeanELResolver to -->
<!-- ensure webapp classloader can be released on undeploy -->
<!-- ==================================================================== -->
<listener>
<listener-class>org.eclipse.jetty.ee9.servlet.listener.ELContextCleaner</listener-class>
</listener>
<!-- ==================================================================== --> <!-- ==================================================================== -->
<!-- Removes static cache of Methods from java.beans.Introspector to --> <!-- Removes static cache of Methods from java.beans.Introspector to -->
<!-- ensure webapp classloader can be released on undeploy --> <!-- ensure webapp classloader can be released on undeploy -->