You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by kk...@apache.org on 2010/12/02 03:26:11 UTC
svn commit: r1041255 - in /tomcat/tc6.0.x/trunk: STATUS.txt
java/org/apache/catalina/loader/WebappClassLoader.java
webapps/docs/changelog.xml
Author: kkolinko
Date: Thu Dec 2 02:26:11 2010
New Revision: 1041255
URL: http://svn.apache.org/viewvc?rev=1041255&view=rev
Log:
Extend threads local memory leak detection / fixing to classes loaded by the JSP class loaders
Based on the patch by Sylvain Laurent
Modified:
tomcat/tc6.0.x/trunk/STATUS.txt
tomcat/tc6.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoader.java
tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml
Modified: tomcat/tc6.0.x/trunk/STATUS.txt
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/STATUS.txt?rev=1041255&r1=1041254&r2=1041255&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/STATUS.txt (original)
+++ tomcat/tc6.0.x/trunk/STATUS.txt Thu Dec 2 02:26:11 2010
@@ -203,13 +203,3 @@ PATCHES PROPOSED TO BACKPORT:
+1: mturk
-0: markt - Patch doesn't apply cleanly to tc6.0.x/trunk
-1:
-
-* Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=48837
- Extend threads local memory leak detection / fixing to classes loaded by the
- JSP class loaders
- Patch by Sylvain Laurent
- https://issues.apache.org/bugzilla/attachment.cgi?id=25116
- +1: markt, kkolinko, kfujino
- -1:
- kkolinko: I'd like to s/isLoadedByThisWebAppClassLoader/isLoadedByThisWebappClassLoader/
- to match this class name. Also do not change JavaDoc at class declaration.
Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoader.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoader.java?rev=1041255&r1=1041254&r2=1041255&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoader.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoader.java Thu Dec 2 02:26:11 2010
@@ -2115,7 +2115,7 @@ public class WebappClassLoader
for (Thread thread : threads) {
if (thread != null) {
ClassLoader ccl = thread.getContextClassLoader();
- if (ccl != null && ccl == this) {
+ if (ccl == this) {
// Don't warn about this thread
if (thread == Thread.currentThread()) {
continue;
@@ -2356,8 +2356,8 @@ public class WebappClassLoader
boolean remove = false;
// Check the key
Object key = ((Reference<?>) table[j]).get();
- if (this.equals(key) || (key != null &&
- this == key.getClass().getClassLoader())) {
+ if (this.equals(key) ||
+ isLoadedByThisWebappClassLoader(key)) {
remove = true;
}
// Check the value
@@ -2365,15 +2365,15 @@ public class WebappClassLoader
table[j].getClass().getDeclaredField("value");
valueField.setAccessible(true);
Object value = valueField.get(table[j]);
- if (this.equals(value) || (value != null &&
- this == value.getClass().getClassLoader())) {
+ if (this.equals(value) ||
+ isLoadedByThisWebappClassLoader(value)) {
remove = true;
}
if (remove) {
Object[] args = new Object[5];
args[0] = contextName;
if (key != null) {
- args[1] = key.getClass().getCanonicalName();
+ args[1] = getPrettyClassName(key.getClass());
try {
args[2] = key.toString();
} catch (Exception e) {
@@ -2385,7 +2385,7 @@ public class WebappClassLoader
}
}
if (value != null) {
- args[3] = value.getClass().getCanonicalName();
+ args[3] = getPrettyClassName(value.getClass());
try {
args[4] = value.toString();
} catch (Exception e) {
@@ -2435,6 +2435,30 @@ public class WebappClassLoader
}
}
+ private String getPrettyClassName(Class clazz) {
+ String name = clazz.getCanonicalName();
+ if(name==null){
+ name = clazz.getName();
+ }
+ return name;
+ }
+
+ /**
+ * @param o object to test
+ * @return true if o has been loaded by the current classloader or one of its descendants.
+ */
+ private boolean isLoadedByThisWebappClassLoader(Object o) {
+ if(o == null) {
+ return false;
+ }
+ for(ClassLoader loader = o.getClass().getClassLoader(); loader != null; loader = loader.getParent()) {
+ if(loader == this) {
+ return true;
+ }
+ }
+ return false;
+ }
+
/*
* Get the set of current threads as an array.
*/
Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?rev=1041255&r1=1041254&r2=1041255&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Thu Dec 2 02:26:11 2010
@@ -80,6 +80,12 @@
to prevent modification. This facilitated, although it wasn't the root
cause, CVE-2010-1622. (markt)
</fix>
+ <add>
+ <bug>48837</bug>: Extend thread local memory leak detection to include
+ classes loaded by subordinate class loaders to the web
+ application's class loader such as the Jasper class loader.
+ Patch provided by Sylvain Laurent. (kkolinko)
+ </add>
<fix>
<bug>49030</bug>: Failure during start of one connector should not leave
some connectors started and some ignored. (kkolinko)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org