Greetings XML-Sec Developers,

My team ran into Bugzilla Bug 29595
(http://issues.apache.org/bugzilla/show_bug.cgi?id=29595) a few weeks ago
and unfortunately it is a showstopper for us.  Our Apache Axis Web Service
servers using Apache WS-FX WSS4J were crashing regularly under load with
OutOfMemoryExceptions, so we began hunting for answers.

I looked at Tom Diepenbrock's ([EMAIL PROTECTED]) proposed patch, but
the XML Security JUnit regressions failed with NullPointer's when I applied
it to the latest CVS.  I've attached a patch much closer to Salvador
Deltoro's original suggestion that appears to both fix the memory leak and
pass the JUnit test cases.  Can one of the committers (and anybody else who
wants to test this out) please take a look and verify my findings?  It would
be great if we could get this or anything else that fixes the problem
committed to the code.

Regards,
Jonathan Anderson
Booz Allen Hamilton
? diff.txt
Index: org/apache/xml/security/utils/IdResolver.java
===================================================================
RCS file: 
/home/cvspublic/xml-security/src/org/apache/xml/security/utils/IdResolver.java,v
retrieving revision 1.16
diff -u -r1.16 IdResolver.java
--- org/apache/xml/security/utils/IdResolver.java       12 May 2004 12:00:46 -0000     
 1.16
+++ org/apache/xml/security/utils/IdResolver.java       6 Jul 2004 20:55:40 -0000
@@ -26,6 +26,7 @@
 import org.w3c.dom.Element;
 
 import java.util.WeakHashMap;
+import java.lang.ref.WeakReference;
 
 
 /**
@@ -73,7 +74,7 @@
           elementMap = new WeakHashMap();
           docMap.put(doc, elementMap);
       }
-      elementMap.put(idValue, element);
+      elementMap.put(idValue, new WeakReference(element));
    }
 
    /**
@@ -208,7 +209,11 @@
       log.debug("getElementByIdType() Search for ID " + id);
        WeakHashMap elementMap = (WeakHashMap) docMap.get(doc);
        if (elementMap != null) {
-           return (Element)elementMap.get(id);
+           WeakReference weakReference = (WeakReference) elementMap.get(id);
+           if (weakReference != null)
+           {
+                return (Element) weakReference.get();   
+           }
        }
        return null;
    }

Reply via email to