You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by akuhtz-2 <an...@gmail.com> on 2012/03/09 13:15:55 UTC
NPE in JAXBEncoderDecoder.findExtraNamespaces()
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-findExtraNamespaces-tp5550405p5550405.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: NPE in JAXBEncoderDecoder.findExtraNamespaces()
Posted by akuhtz-2 <an...@gmail.com>.
Fix successfully verified ;-)
Thanks.
Andi
--
View this message in context: http://cxf.547215.n5.nabble.com/NPE-in-JAXBEncoderDecoder-findExtraNamespaces-tp5550405p5570222.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: NPE in JAXBEncoderDecoder.findExtraNamespaces()
Posted by Daniel Kulp <dk...@apache.org>.
Doh!!!
You're right. Fix committed.
Dan
On Thursday, March 15, 2012 10:15:26 AM akuhtz-2 wrote:
> Hi Dan,
>
> Sorry for the late reply but I'm not sure if the fix
> (http://cxf.547215.n5.nabble.com/svn-commit-r1298956-cxf-trunk-rt-databind
> ing-jaxb-src-main-java-org-apache-cxf-jaxb-JAXBEncoderDecoda-td5551363.htm
> l) really solves the problem.
>
> Shouldn't it be
>
> nsMap.put(*""*, ns[x + 1]);
>
> instead of
>
> nsMap.put(*null*, ns[x + 1]);
>
> if ns[x] == null ??
>
> Just tried with the current 2.5.3-SNAPSHOT and the NPE is still in ....
>
> Regards,
> Andi
>
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/NPE-in-JAXBEncoderDecoder-findExtraNamesp
> aces-tp5550405p5568673.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
Re: NPE in JAXBEncoderDecoder.findExtraNamespaces()
Posted by akuhtz-2 <an...@gmail.com>.
Hi Dan,
Sorry for the late reply but I'm not sure if the fix
(http://cxf.547215.n5.nabble.com/svn-commit-r1298956-cxf-trunk-rt-databinding-jaxb-src-main-java-org-apache-cxf-jaxb-JAXBEncoderDecoda-td5551363.html)
really solves the problem.
Shouldn't it be
nsMap.put(*""*, ns[x + 1]);
instead of
nsMap.put(*null*, ns[x + 1]);
if ns[x] == null ??
Just tried with the current 2.5.3-SNAPSHOT and the NPE is still in ....
Regards,
Andi
--
View this message in context: http://cxf.547215.n5.nabble.com/NPE-in-JAXBEncoderDecoder-findExtraNamespaces-tp5550405p5568673.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: NPE in JAXBEncoderDecoder.findExtraNamespaces()
Posted by Daniel Kulp <dk...@apache.org>.
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