Faced NullPointException during CXF HTTPConduit with a request.
Environment
- Red Hat JBoss Fuse
- 6.1.0
Issue
- One off NPE when invoking a WS using CXF.
2015-09-29 11:39:29,173 WARN (Camel (xxx-yyy) thread #13044 - Threads) [org.apache.cxf.phase.PhaseInterceptorChain] XXX-SOME_ID-YYY xxx-yyy:fulfilment-route Interceptor for {http://xxx.yyy.com/abc}ABC#{http://xxx.yyy.com/abc}ABC has thrown exception, unwinding now
java.lang.NullPointerException: NullPointerException invoking http://HOSTNAME:8080/abc: null
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)[:1.7.0_51]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)[:1.7.0_51]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)[:1.7.0_51]
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)[:1.7.0_51]
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:1339)[170:org.apache.cxf.cxf-rt-transports-http:2.7.0.redhat-610379]
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1328)[170:org.apache.cxf.cxf-rt-transports-http:2.7.0.redhat-610379]
at org.apache.cxf.io.CacheAndWriteOutputStream.postClose(CacheAndWriteOutputStream.java:50)[164:org.apache.cxf.cxf-api:2.7.0.redhat-610379]
at org.apache.cxf.io.CachedOutputStream.close(CachedOutputStream.java:223)[164:org.apache.cxf.cxf-api:2.7.0.redhat-610379]
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)[164:org.apache.cxf.cxf-api:2.7.0.redhat-610379]
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:628)[170:org.apache.cxf.cxf-rt-transports-http:2.7.0.redhat-610379]
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)[164:org.apache.cxf.cxf-api:2.7.0.redhat-610379]
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)[164:org.apache.cxf.cxf-api:2.7.0.redhat-610379]
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:565)[164:org.apache.cxf.cxf-api:2.7.0.redhat-610379]
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:467)[164:org.apache.cxf.cxf-api:2.7.0.redhat-610379]
at org.apache.camel.component.cxf.CxfProducer.process(CxfProducer.java:112)[205:org.apache.camel.camel-cxf:2.12.0.redhat-610379]
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:91)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at xxx.yyy.zzz.process(XYZ_Class.java:192)[367:XYZ_jar:1.1.17]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:91)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:91)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.builder.NoErrorHandlerBuilder$1.process(NoErrorHandlerBuilder.java:40)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:51)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:91)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at xxx.yyy.zzz$MetricsProcessor.process(XYZ_Class.java:192)[367:XYZ_jar:1.1.17]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:91)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.processor.TryProcessor.process(TryProcessor.java:111)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.processor.TryProcessor.process(TryProcessor.java:82)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:91)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at xxx.yyy.zzz.process(XYZ_Class.java:192)[367:XYZ_jar:1.1.17]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:91)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:51)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:91)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at xxx.yyy.zzz.process(XYZ_Class.java:192)[367:XYZ_jar:1.1.17]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:91)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.processor.Pipeline.access$100(Pipeline.java:43)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.processor.Pipeline$1.done(Pipeline.java:136)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.processor.ThreadsProcessor$ProcessCall.run(ThreadsProcessor.java:83)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.7.0_51]
at java.util.concurrent.FutureTask.run(FutureTask.java:262)[:1.7.0_51]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[:1.7.0_51]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_51]
at java.lang.Thread.run(Thread.java:744)[:1.7.0_51]
Caused by: java.lang.NullPointerException
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1313)[170:org.apache.cxf.cxf-rt-transports-http:2.7.0.redhat-610379]
... 56 more
- Production issue, only seen it happen once.
Resolution
- Issue is not reproducible hence difficult to identify exact issue.
- It fails at line number 1313 of HTTPConduit class. We see here that there is a null check but still it throws null pointer exception.
HTTPConduit.java
1309 try {
1310 handleResponse();
1311 } finally {
1312 if (cachingForRetransmission && cachedStream != null) {
1313 cachedStream.close();
1314 }
1315 }
- This cachedStream is a complex object having other streams. So might be one of them is null at the time request processed.
- Reproducer was created to simulate problem but with multiple load-test on this reproducer did not see same exception.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments