xml-xmlbeans-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sal.camp...@hp.com
Subject RE: [PATCH] QNameHelper.suggestPrefix NullPointerException
Date Fri, 30 Jul 2004 01:27:41 GMT
Eric,

You are correct...I had realized this on my way home.....I had actually
seen a null being passed to the method....

JavaQNameHolder contains an inner class:

 private static class PrettyNamespaceManager implements NamespaceManager
    {
        public String find_prefix_for_nsuri(String nsuri, String
suggested_prefix)
        {
            return QNameHelper.suggestPrefix(suggested_prefix);
        }
        public String getNamespaceForPrefix(String prefix)
        {
            return prefix;
        }
    }

In both places where find_prefix_for_nsuri is being called a null is being
passed in for the suggested_prefix parameter...

The code needs to be changed to pss the "nsuri" param to the
QNameHelper.suggestPrefix operation....So the real fix is in the
PrettyNamespaceManager.find_prefix_for_nsuri

Should I submit patched files for these or will you make the modification??

thanks!

-Sal

> 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
> 856.638.6284
> sal_campana@hp.com <mailto:sal_campana@hp.com>
> <mailto:sal_campana@hp.com>
>
>


- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-dev-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/


Mime
View raw message