Description
In my usage of CXF-RS with Camel through the camel-cxf component I ran into a NullpointerException, the specific case is described in some detail on StackOverflow: http://stackoverflow.com/questions/4198461/why-do-i-get-a-nullpointerexception-when-invoking-the-cxf-rs-endpoint-of-a-camel
Specifically I run into a NullpointerException:
Caused by: java.lang.NullPointerException at org.apache.camel.component.cxf.jaxrs.CxfRsInvoker.getContinuation(CxfRsInvoker.java:63) at org.apache.camel.component.cxf.jaxrs.CxfRsInvoker.performInvocation(CxfRsInvoker.java:52) at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:89) ... 33 more
I was assuming I was misconfiguring something but didn't find any alternative way so I started digging in the camel-cxf source code.
I found that such a "getContinuation" method also exists for the org.apache.camel.component.cxf.CxfConsumer as well as for the CxfRsInvoker (where it was failing for me). However in the case of the CxfConsumer there is a guard on the ContinuationProvider so that if it is null, then null is returned:
return provider == null ? null : provider.getContinuation();
CxfRsInvoker does not have this guard, but it does have code to deal with a "null" Continuation at the calling site (line 52, in performInvocation). Therefore I assumed this was a bug and patched the guard into the CxfRsInvoker as well.
My program now seems to work correctly. I assume this is a bug.
For completeness sake, this is what getContinuation now looks like for me:
private Continuation getContinuation(Exchange cxfExchange) { ContinuationProvider provider = (ContinuationProvider)cxfExchange.getInMessage().get(ContinuationProvider.class.getName()); return provider == null ? null : provider.getContinuation(); }