tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r795738 - in /tomcat/container/tc5.5.x: catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java webapps/docs/changelog.xml
Date Mon, 20 Jul 2009 10:14:31 GMT
Author: markt
Date: Mon Jul 20 10:14:30 2009
New Revision: 795738

URL: http://svn.apache.org/viewvc?rev=795738&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=41059
Reduce errors if using ENABLE_CLEAR_REFERENCES=true
Patch by Curt Arnold

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?rev=795738&r1=795737&r2=795738&view=diff
==============================================================================
--- 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
Mon Jul 20 10:14:30 2009
@@ -1617,7 +1617,31 @@
         // Null out any static or final fields from loaded classes,
         // as a workaround for apparent garbage collection bugs
         if (ENABLE_CLEAR_REFERENCES) {
-            Iterator loadedClasses = ((HashMap) resourceEntries.clone()).values().iterator();
+            java.util.Collection values =
+                ((HashMap) resourceEntries.clone()).values();
+            Iterator loadedClasses = values.iterator();
+            //
+            // walk through all loaded class to trigger initialization for
+            //    any uninitialized classes, otherwise initialization of
+            //    one class may call a previously cleared class.
+            while (loadedClasses.hasNext()) {
+                ResourceEntry entry = (ResourceEntry) loadedClasses.next();
+                if (entry.loadedClass != null) {
+                    Class clazz = entry.loadedClass;
+                    try {
+                        Field[] fields = clazz.getDeclaredFields();
+                        for (int i = 0; i < fields.length; i++) {
+                            if(Modifier.isStatic(fields[i].getModifiers())) {
+                                fields[i].get(null);
+                                break;
+                            }
+                        }
+                    } catch(Throwable t) {
+                        // Ignore
+                    }
+                }
+            }
+            loadedClasses = values.iterator();
             while (loadedClasses.hasNext()) {
                 ResourceEntry entry = (ResourceEntry) loadedClasses.next();
                 if (entry.loadedClass != null) {

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?rev=795738&r1=795737&r2=795738&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/webapps/docs/changelog.xml (original)
+++ tomcat/container/tc5.5.x/webapps/docs/changelog.xml Mon Jul 20 10:14:30 2009
@@ -34,14 +34,28 @@
 <body>
 <section name="Tomcat 5.5.29 (fhanik)">
   <subsection name="General">
+    <changelog>
+    </changelog>
   </subsection>
   <subsection name="Catalina">
+    <changelog>
+      <fix>
+        <bug>41059</bug>: Reduce the chances of errors when using
+        ENABLE_CLEAR_REFERENCES. Patch by Curt Arnold. (markt) 
+      </fix>
+    </changelog>
   </subsection>
   <subsection name="Coyote">
+    <changelog>
+    </changelog>
   </subsection>
   <subsection name="Jasper">
+    <changelog>
+    </changelog>
   </subsection>
   <subsection name="Cluster">
+    <changelog>
+    </changelog>
   </subsection>
   <subsection name="Webapps">
     <changelog>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message