cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kulp <dk...@apache.org>
Subject Re: NPE in JAXBEncoderDecoder.findExtraNamespaces()
Date Fri, 09 Mar 2012 17:03:14 GMT

This bug made me laugh......   easy to fix though.

The issue is that woodstox internally uses a "null" prefix for the default 
prefix.   When we create the nsMap, we just call:
treeMap.put(pfx, ns)

which, in this case, the pfx is null.   If you look at the javadoc for 
TreeMap's put call, you see:

     * @throws NullPointerException if the specified key is null
     *         and this map uses natural ordering, or its comparator
     *         does not permit null keys

so it SHOULD be throwing a NullPointerException at that point.   But it's 
not.  If you actually look at the code for the TreeMap in the JDK, you see 
this nice comment:

	    // TBD:
	    // 5045147: (coll) Adding null to an empty TreeSet should
	    // throw NullPointerException
	    //
	    // compare(key, key); // type check

So they are actually aware of it.  If you look at the comments for that bug:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5045147

"Unfortunately, this fix exposed too many bugs in Other Peoples' Code, so 
backed out for now."


Anyway, it's a simple fix for us to not add the null key (we use "" in other 
places and for non-woodstox).   But I thought I'd mention that it gave me a 
little chuckle.

Dan




On Friday, March 09, 2012 04:15:55 AM akuhtz-2 wrote:
> Hi,
> 
> I've found a case where a NPE is thrown in
> JAXBEncoderDecoder.findExtraNamespaces(). I've attached a sample project
> that shows the problem.
> 
> The following request passes:
> <Envelope xmlns="http://www.w3.org/2003/05/soap-envelope"
>     xmlns:val="http://cxf.apache.org/jaxws/schemavalidation" >
>     <Body>
>         <val:ckRequest>
>             <val:request id="aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" />
>         </val:ckRequest>
>     </Body>
> </Envelope>
> 
> But this requests causes an NPE:
> <Envelope xmlns="http://www.w3.org/2003/05/soap-envelope">
>     <Body>
>         <val:ckRequest
> xmlns:val="http://cxf.apache.org/jaxws/schemavalidation">
>             <val:request id="aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" />
>         </val:ckRequest>
>     </Body>
> </Envelope>
> 
> Shall I create a JIRA issue?
> 
> Regards
> Andi http://cxf.547215.n5.nabble.com/file/n5550405/cxf-problem.zip
> cxf-problem.zip
> 
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/NPE-in-JAXBEncoderDecoder-findExtraNamesp
> aces-tp5550405p5550405.html Sent from the cxf-user mailing list archive at
> Nabble.com.
-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com


Mime
View raw message