View | Details | Raw Unified | Return to bug 41059
Collapse All | Expand All

(-)java/org/apache/catalina/loader/WebappClassLoader.java (-1 / +23 lines)
Lines 1617-1623 Link Here
1617
        // Null out any static or final fields from loaded classes,
1617
        // Null out any static or final fields from loaded classes,
1618
        // as a workaround for apparent garbage collection bugs
1618
        // as a workaround for apparent garbage collection bugs
1619
        if (ENABLE_CLEAR_REFERENCES) {
1619
        if (ENABLE_CLEAR_REFERENCES) {
1620
            Iterator loadedClasses = ((HashMap) resourceEntries.clone()).values().iterator();
1620
            java.util.Collection values = ((HashMap) resourceEntries.clone()).values();
1621
            Iterator loadedClasses = values.iterator();
1622
            //
1623
            // walk through all loaded class to trigger initialization for
1624
            //    any uninitialized classes, otherwise initialization of
1625
            //    one class may call a previously cleared class.
1626
            while(loadedClasses.hasNext()) {
1627
                ResourceEntry entry = (ResourceEntry) loadedClasses.next();
1628
                if (entry.loadedClass != null) {
1629
                    Class clazz = entry.loadedClass;
1630
                    try {
1631
                        Field[] fields = clazz.getDeclaredFields();
1632
                        for (int i = 0; i < fields.length; i++) {
1633
                            if(Modifier.isStatic(fields[i].getModifiers())) {
1634
                                fields[i].get(null);
1635
                                break;
1636
                            }
1637
                        }
1638
                    } catch(Throwable t) {
1639
                    }
1640
                }
1641
            }
1642
            loadedClasses = values.iterator();
1621
            while (loadedClasses.hasNext()) {
1643
            while (loadedClasses.hasNext()) {
1622
                ResourceEntry entry = (ResourceEntry) loadedClasses.next();
1644
                ResourceEntry entry = (ResourceEntry) loadedClasses.next();
1623
                if (entry.loadedClass != null) {
1645
                if (entry.loadedClass != null) {

Return to bug 41059