Repository: cxf Updated Branches: refs/heads/master dcb407024 -> 0c307b673
[CXF-7412] avoid NPE occuring when handler chain contains a SoapHandler and empty message is received Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/0c307b67 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/0c307b67 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/0c307b67 Branch: refs/heads/master Commit: 0c307b67340dcafd75a1fd40ce003869ddd4594b Parents: dcb4070 Author: Dennis Kieselhorst <d...@apache.org> Authored: Wed Jul 5 11:39:22 2017 +0200 Committer: Dennis Kieselhorst <d...@apache.org> Committed: Wed Jul 5 11:39:22 2017 +0200 ---------------------------------------------------------------------- .../handler/soap/SOAPHandlerInterceptor.java | 47 ++++++++++---------- 1 file changed, 24 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/0c307b67/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java index 2122eff..340c966 100644 --- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java +++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java @@ -254,35 +254,36 @@ public class SOAPHandlerInterceptor extends Exchange exch = message.getExchange(); setupBindingOperationInfo(exch, sm); SOAPMessage msg = sm.getMessage(); - try { - List<SOAPElement> params = new ArrayList<>(); - message.put(MessageContext.REFERENCE_PARAMETERS, params); - SOAPHeader head = SAAJUtils.getHeader(msg); - if (head != null) { - Iterator<Node> it = CastUtils.cast(head.getChildElements()); - while (it != null && it.hasNext()) { - Node nd = it.next(); - if (nd instanceof SOAPElement) { - SOAPElement el = (SOAPElement)nd; - if (el.hasAttributeNS(Names.WSA_NAMESPACE_NAME, "IsReferenceParameter") - && ("1".equals(el.getAttributeNS(Names.WSA_NAMESPACE_NAME, - "IsReferenceParameter")) - || Boolean.parseBoolean(el.getAttributeNS(Names.WSA_NAMESPACE_NAME, - "IsReferenceParameter")))) { - params.add(el); + if (msg != null) { + try { + List<SOAPElement> params = new ArrayList<>(); + message.put(MessageContext.REFERENCE_PARAMETERS, params); + SOAPHeader head = SAAJUtils.getHeader(msg); + if (head != null) { + Iterator<Node> it = CastUtils.cast(head.getChildElements()); + while (it != null && it.hasNext()) { + Node nd = it.next(); + if (nd instanceof SOAPElement) { + SOAPElement el = (SOAPElement) nd; + if (el.hasAttributeNS(Names.WSA_NAMESPACE_NAME, "IsReferenceParameter") + && ("1".equals(el.getAttributeNS(Names.WSA_NAMESPACE_NAME, + "IsReferenceParameter")) + || Boolean.parseBoolean(el.getAttributeNS(Names.WSA_NAMESPACE_NAME, + "IsReferenceParameter")))) { + params.add(el); + } } } } + if (isRequestor(message) && msg.getSOAPPart().getEnvelope().getBody() != null + && msg.getSOAPPart().getEnvelope().getBody().hasFault()) { + return null; + } + } catch (SOAPException e) { + throw new Fault(e); } - if (isRequestor(message) && msg.getSOAPPart().getEnvelope().getBody() != null - && msg.getSOAPPart().getEnvelope().getBody().hasFault()) { - return null; - } - } catch (SOAPException e) { - throw new Fault(e); } - return sm; }