cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kulp <>
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:

"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.


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=""
>     xmlns:val="" >
>     <Body>
>         <val:ckRequest>
>             <val:request id="aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" />
>         </val:ckRequest>
>     </Body>
> </Envelope>
> But this requests causes an NPE:
> <Envelope xmlns="">
>     <Body>
>         <val:ckRequest
> xmlns:val="">
>             <val:request id="aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" />
>         </val:ckRequest>
>     </Body>
> </Envelope>
> Shall I create a JIRA issue?
> Regards
> Andi
> --
> View this message in context:
> aces-tp5550405p5550405.html Sent from the cxf-user mailing list archive at
Daniel Kulp -
Talend Community Coder -

View raw message