Author: mrglavas
Date: Sun Feb 26 20:47:44 2006
New Revision: 381260

URL: http://svn.apache.org/viewcvs?rev=381260&view=rev
Log:
JIRA Issue #1068:
http://issues.apache.org/jira/browse/XERCESJ-1068

Instead of interning namespace parameters and using "==", just use equals().
I'm not convinced that there was a bug here but this does make the code a bit 
safer.

Modified:
    xerces/java/trunk/src/org/apache/xerces/impl/xs/util/XSNamedMap4Types.java
    xerces/java/trunk/src/org/apache/xerces/impl/xs/util/XSNamedMapImpl.java

Modified: 
xerces/java/trunk/src/org/apache/xerces/impl/xs/util/XSNamedMap4Types.java
URL: 
http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xerces/impl/xs/util/XSNamedMap4Types.java?rev=381260&r1=381259&r2=381260&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/util/XSNamedMap4Types.java 
(original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/util/XSNamedMap4Types.java 
Sun Feb 26 20:47:44 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002,2004 The Apache Software Foundation.
+ * Copyright 2002,2004,2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -102,10 +102,8 @@
      *   identify any <code>XSObject</code> in this map.
      */
     public XSObject itemByName(String namespace, String localName) {
-        if (namespace != null)
-            namespace = namespace.intern();
         for (int i = 0; i < fNSNum; i++) {
-            if (namespace == fNamespaces[i]) {
+            if (isEqual(namespace, fNamespaces[i])) {
                 XSTypeDefinition type = 
(XSTypeDefinition)fMaps[i].get(localName);
                 // only return it if it mataches the required type
                 if (type.getTypeCategory() == fType)

Modified: 
xerces/java/trunk/src/org/apache/xerces/impl/xs/util/XSNamedMapImpl.java
URL: 
http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xerces/impl/xs/util/XSNamedMapImpl.java?rev=381260&r1=381259&r2=381260&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/util/XSNamedMapImpl.java 
(original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/util/XSNamedMapImpl.java 
Sun Feb 26 20:47:44 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002,2004 The Apache Software Foundation.
+ * Copyright 2002,2004,2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -133,10 +133,8 @@
      *   identify any <code>XSObject</code> in this map.
      */
     public XSObject itemByName(String namespace, String localName) {
-        if (namespace != null)
-            namespace = namespace.intern();
         for (int i = 0; i < fNSNum; i++) {
-            if (namespace == fNamespaces[i]) {
+            if (isEqual(namespace, fNamespaces[i])) {
                 // when this map is created from SymbolHash's
                 // get the component from SymbolHash
                 if (fMaps != null)
@@ -179,6 +177,10 @@
         if (index < 0 || index >= fLength)
             return null;
         return fArray[index];
+    }
+    
+    final boolean isEqual(String one, String two) {
+        return (one == two || (one != null && one.equals(two)));
     }
     
 } // class XSNamedMapImpl



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

Reply via email to