DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=41059>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=41059


[EMAIL PROTECTED] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |




------- Additional Comments From [EMAIL PROTECTED]  2006-12-05 05:47 -------
Here is a new patch that disables only the code which resets the static and 
final variables.

--- WebappClassLoader.java.orig 2006-09-12 11:12:42.000000000 -0400
+++ WebappClassLoader.java      2006-12-05 08:34:52.000000000 -0500
@@ -163,7 +163,16 @@ public class WebappClassLoader
      * resources.
      */
     boolean antiJARLocking = false;
-
+
+    /**
+     * Use experimental code in clearReferences to reset static and final 
variables
+     * to deal with possible memory leaks.
+     */
+    private static final boolean ENABLE_NULLING_STATIC_FINAL_REFERENCES =
+            Boolean.valueOf(System.getProperty(
+                    "org.apache.catalina.loader.WebappClassLoader.ENABLE_NULLI
NG_STATIC_FINAL_REFERENCES",
+                    "true")).booleanValue();
+

     // ----------------------------------------------------------- 
Constructors

@@ -1585,46 +1594,48 @@ public class WebappClassLoader

         // Null out any static or final fields from loaded classes,
         // as a workaround for apparent garbage collection bugs
-        Iterator loadedClasses = ((HashMap) resourceEntries.clone()).values
().iterator();
-        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++) {
-                        Field field = fields[i];
-                        int mods = field.getModifiers();
-                        if (field.getType().isPrimitive()
-                                || (field.getName().indexOf("$") != -1)) {
-                            continue;
-                        }
-                        if (Modifier.isStatic(mods)) {
-                            try {
-                                field.setAccessible(true);
-                                if (Modifier.isFinal(mods)) {
-                                    if (!((field.getType().getName
().startsWith("java."))
-                                            || (field.getType().getName
().startsWith("javax.")))) {
-                                        nullInstance(field.get(null));
+        if(ENABLE_NULLING_STATIC_FINAL_REFERENCES) {
+            Iterator loadedClasses = ((HashMap) resourceEntries.clone
()).values().iterator();
+            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++) {
+                            Field field = fields[i];
+                            int mods = field.getModifiers();
+                            if (field.getType().isPrimitive()
+                                    || (field.getName().indexOf("$") != -1)) {
+                                continue;
+                            }
+                            if (Modifier.isStatic(mods)) {
+                                try {
+                                    field.setAccessible(true);
+                                    if (Modifier.isFinal(mods)) {
+                                        if (!((field.getType().getName
().startsWith("java."))
+                                                || (field.getType().getName
().startsWith("javax.")))) {
+                                            nullInstance(field.get(null));
+                                        }
+                                    } else {
+                                        field.set(null, null);
+                                        if (log.isDebugEnabled()) {
+                                            log.debug("Set field " + 
field.getName()
+                                                    + " to null in class " + 
clazz.getName());
+                                        }
                                     }
-                                } else {
-                                    field.set(null, null);
+                                } catch (Throwable t) {
                                     if (log.isDebugEnabled()) {
-                                        log.debug("Set field " + field.getName
()
-                                                + " to null in class " + 
clazz.getName());
+                                        log.debug("Could not set field " + 
field.getName()
+                                                + " to null in class " + 
clazz.getName(), t);
                                     }
                                 }
-                            } catch (Throwable t) {
-                                if (log.isDebugEnabled()) {
-                                    log.debug("Could not set field " + 
field.getName()
-                                            + " to null in class " + 
clazz.getName(), t);
-                                }
                             }
                         }
-                    }
-                } catch (Throwable t) {
-                    if (log.isDebugEnabled()) {
-                        log.debug("Could not clean fields for class " + 
clazz.getName(), t);
+                    } catch (Throwable t) {
+                        if (log.isDebugEnabled()) {
+                            log.debug("Could not clean fields for class " + 
clazz.getName(), t);
+                        }
                     }
                 }
             }


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to