Bugs item #2789052, was opened at 2009-05-08 17:08
Message generated for change (Tracker Item Submitted) made by kaeppler
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=116035&aid=2789052&group_id=16035

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Matthias (kaeppler)
Assigned to: Nobody/Anonymous (nobody)
Summary: NamespaceStack.getAttributeQName caches incorrectly

Initial Comment:
Affects dom4j 1.6.1 (tested on Android 1.1 / Apache Harmony)

I just discovered a serious flaw in the caching of QName objects in 
NamespaceStack, which results in getting attributes by name only ever works for 
the first parsed attribute. The problem being with this method:

    public QName getAttributeQName(String namespaceURI, String localName,
            String qualifiedName) {
        if (qualifiedName == null) {
            qualifiedName = localName;
        }

        Map map = getNamespaceCache();
        QName answer = (QName) map.get(qualifiedName);

        if (answer != null) {
            return answer;
        }
    ...
    }

if qualifiedName is the empty string instead of null (which is the case for all 
attribute nodes being parsed), then this method always returns the same QName 
object from the cache! Hence, calling node.attribute("a") will return the 
attribute a if and only if it was parsed before all other attributes; for any 
other attribute name, that method returns null.

I don't have enough insight to tell whether the problem is with this exact 
method or if qualifiedName shouldn't ever be the empty string in the first 
place. One way or the other, it's broken.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=116035&aid=2789052&group_id=16035

------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
dom4j-dev mailing list
dom4j-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-dev

Reply via email to