Hi Mukul, Mukul Gandhi <[email protected]> wrote on 07/24/2010 12:52:13 PM:
> Hi Michael, > > On Sat, Jul 24, 2010 at 9:45 PM, Michael Glavassevich > <[email protected]> wrote: > > Is there a reason why you're calling String.equals()? Prefixes and > URIs are interned strings > > across Xerces. They are compared using '==' for performance reasons. > > While working on this change, I really did not want to write anything > into NamespaceSupport.java. > > I really wanted to use the method "getURI" of this class. But this was > returning a null value given a specific "namespace prefix" (but a > non-null URI really existed in the buffer). After I changed the > implementation of "getURI" to use String.equals() instead of '==' this > problem disappeared, and I could observe the functionality working > correctly. > > And I correspondingly changed '==' to String.equals() in getPrefix > (which I really did not invoke for this change, but did that for > consistency with the getURI change). > > I hope this change is acceptable, as it solved a possible bug during > my testing. No, not really. :-) You're not using the class as it was intended to be used. The bug is in how you were using the method, not in NamespaceSupport. Flipping NamespaceSupport to use String.equals() has an impact on several critical code paths through Xerces. It hurts performance of the parser and other components, so is not a change I would support. Wherever you call getPrefix() or getURI() you need to make sure that the string you're passing in has been interned (i.e. String.intern()) or has been passed through a SymbolTable [1]. > -- > Regards, > Mukul Gandhi > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] Thanks.> [1] http://xerces.apache.org/xerces2-j/javadocs/xerces2/org/apache/xerces/util/SymbolTable.html Michael Glavassevich XML Parser Development IBM Toronto Lab E-mail: [email protected] E-mail: [email protected]
