Author: markt Date: Wed Oct 18 16:32:37 2006 New Revision: 465418 URL: http://svn.apache.org/viewvc?view=rev&rev=465418 Log: Fix bug 38048. memory leak with EL in JSPs. Patch provided by Taras Tielkes.
Modified: tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java tomcat/container/tc5.5.x/webapps/docs/changelog.xml Modified: tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java?view=diff&rev=465418&r1=465417&r2=465418 ============================================================================== --- tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java (original) +++ tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java Wed Oct 18 16:32:37 2006 @@ -41,7 +41,10 @@ import java.util.ArrayList; import java.util.Enumeration; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; +import java.util.Map; +import java.util.Set; import java.util.Vector; import java.util.jar.Attributes; import java.util.jar.JarEntry; @@ -1630,7 +1633,10 @@ } } - // Clear the IntrospectionUtils cache. + // Remove entries for this webapp from the JSP EL BeanInfo cache + cleanElCache(); + + // Clear the IntrospectionUtils cache. IntrospectionUtils.clear(); // Clear the classloader reference in common-logging @@ -1642,6 +1648,34 @@ } + protected void cleanElCache() { + try { + Class managerClass = + Class.forName("org.apache.commons.el.BeanInfoManager"); + Field cacheField = + managerClass.getDeclaredField("mBeanInfoManagerByClass"); + cacheField.setAccessible(true); + Map map = (Map) cacheField.get(null); + + Set victims = new HashSet(); + + for (Iterator i = map.keySet().iterator(); i.hasNext();) { + Class cachedClass = (Class) i.next(); + if(loadedByThisOrChild(cachedClass)) { + victims.add(cachedClass); + } + } + + map.keySet().removeAll(victims); + + } catch (Throwable t) { + if (log.isDebugEnabled()) { + log.debug("Could not clean EL cache", t); + } + } + } + + protected void nullInstance(Object instance) { if (instance == null) { return; Modified: tomcat/container/tc5.5.x/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/webapps/docs/changelog.xml?view=diff&rev=465418&r1=465417&r2=465418 ============================================================================== --- tomcat/container/tc5.5.x/webapps/docs/changelog.xml (original) +++ tomcat/container/tc5.5.x/webapps/docs/changelog.xml Wed Oct 18 16:32:37 2006 @@ -79,6 +79,10 @@ Patch provided by Tristan Marly. (markt) </fix> <fix> + <bug>38048</bug>: Fix memory leak assoaciated with use of expression + language in JSPs. Patch provided by Taras Tielkes. (markt) + </fix> + <fix> <bug>40633</bug>: Remove references to the DefaultContext from the documentation. (markt) </fix> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]