[ http://issues.apache.org/jira/browse/XERCESJ-1068?page=all ]

Nathan Beyer updated XERCESJ-1068:
----------------------------------

    Attachment: XSNamedMapImpl_patch.txt

This object's base class doesn't guarntee that the fNamespaces field contains 
only "interned" Strings when it's constructed. The attached patch adds a few 
snippets of code to XSNamedMapImpl, the base class, which interns all namespace 
strings that are passed. I think this is probably the most appropriate thing to 
do, so that the "==" operator comparisions in XSNamedMapImpl and subclasses are 
guaranteed.

I did trace the code back and it looks like it should get interned somewhere in 
the parsing, specifically as the namespace is added to a SymbolTable, but that 
seems like a dangerous assumption for such a large code base.

An alternative to this would be just enhancing the checks to do both "==" and 
".equals" checks. In the grand scheme of things, that in combonation with 
removing the interning of the namespace parameters passed would perfom just as 
wel.

> XSNamedMap4Types.java: Doing Object comparison when Strings are compared
> ------------------------------------------------------------------------
>
>          Key: XERCESJ-1068
>          URL: http://issues.apache.org/jira/browse/XERCESJ-1068
>      Project: Xerces2-J
>         Type: Bug
>   Components: XML Schema datatypes
>     Versions: 2.6.2
>     Reporter: Anil Saldhana
>  Attachments: XSNamedMapImpl_patch.txt
>
> public XSObject itemByName(String namespace, String localName) {
>         if (namespace != null)
>             namespace = namespace.intern();
>         for (int i = 0; i < fNSNum; i++) {
>             if (namespace == fNamespaces[i]) {
>                 XSTypeDefinition type = 
> (XSTypeDefinition)fMaps[i].get(localName);
>                 // only return it if it mataches the required type
>                 if (type.getTypeCategory() == fType)
>                     return type;
>                 return null;
>             }
>         }
>         return null;
>     }
> You are doing object comparison, when you should be doing the following:
> if(namespace.equals(fNamespaces[i]))

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


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

Reply via email to