xml-xmlbeans-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Vasilik" <eric...@bea.com>
Subject RE: [PATCH] QNameHelper.suggestPrefix NullPointerException
Date Thu, 29 Jul 2004 21:13:12 GMT
In what situation is this happening?  I believe that the contract of
this method is to have a non null argument (we may want to add an
assert).  There is probably a bug in other code calling this function.
- Eric
-----Original Message-----
From: Campana Jr., Salvatore J [mailto:sal.campana@hp.com] 
Sent: Thursday, July 29, 2004 2:07 PM
To: xmlbeans-dev@xml.apache.org
Subject: [PATCH] QNameHelper.suggestPrefix NullPointerException
I've encountered a NullPointer in the QNameHelper.suggestPrefix
operation.  If the passed-in namespace is null, then the call to
.length() will throw a NullPointerException
The proposed fix is to check for null, and if namespace==null return
"ns" as is done at the bottom of the method as a last resort for
determining a prefix....
public static String suggestPrefix(String namespace)
        if (namespace == null)
            return "ns"; 

        String result = (String)WELL_KNOWN_PREFIXES.get(namespace);
        if (result != null)
            return result;
        int len = namespace.length();
The attached [patched] file is from the current V1 src tree...the
problem exists in both V1 and V2 src trees..
Can we get this patch applied?
Thank you,
Sal Campana

Sal Campana
HP Software
sal_campana@hp.com <mailto:sal_campana@hp.com>  

View raw message