Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.4.4
-
None
-
Unknown
Description
WebFaultOutInterceptor reports NullPointerException when message content doesn't contains Exception.
I was trying to create custom interceptor to transform SoapFault to SoapMessage (read more) and when I registered interceptor like:
InternalActServiceFaultOutInterceptor.java
public class InternalActServiceFaultOutInterceptor extends AbstractSoapInterceptor { public InternalActServiceFaultOutInterceptor() { super(Phase.PRE_STREAM); addBefore(Arrays.asList(StaxOutInterceptor.class.getName(), AttachmentOutInterceptor.class.getName())); } @Override public void handleMessage(SoapMessage soapMessage) throws Fault { Exception exception = soapMessage.getContent(Exception.class); if (exception != null) { soapMessage.getExchange().put(Exception.class, null); for (Class<?> contentFormat : soapMessage.getContentFormats()) { soapMessage.setContent(contentFormat, null); } soapMessage.setContent(List.class, new MessageContentsList(createSoapMessage(RegisterDocumentResponse.class))); } } private <T> RegisterDocumentResponse createSoapMessage(Class<T> messageType) { RegisterDocumentResponse response = new RegisterDocumentResponse(); response.setStatus(ServiceStatusType.SUCCESS); return response; } }
I saw:
WARN [http-8080-1][,,][PhaseInterceptorChain.doLog()] Interceptor for {http://...}InternalActServiceImplService#{http://...}registerDocument has thrown exception, unwinding now java.lang.NullPointerException at org.apache.cxf.jaxws.interceptors.WebFaultOutInterceptor.handleMessage(WebFaultOutInterceptor.java:83) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263) at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:105) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:323) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:206) at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:218) at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:200) at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:114) at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:184) at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:107) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
It's all because WebFaultOutInterceptor expecting in line 83 Fault in message.