cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [2/2] cxf git commit: [CXF-7412] avoid NPE occuring when handler chain contains a SoapHandler and empty message is received
Date Wed, 05 Jul 2017 09:51:44 GMT
[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/5958e971
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/5958e971
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/5958e971

Branch: refs/heads/3.0.x-fixes
Commit: 5958e9711ee4a3204ad486cda22d62da5acb61f3
Parents: 5f15b86
Author: Dennis Kieselhorst <deki@apache.org>
Authored: Wed Jul 5 11:39:22 2017 +0200
Committer: Dennis Kieselhorst <deki@apache.org>
Committed: Wed Jul 5 11:48:19 2017 +0200

----------------------------------------------------------------------
 .../handler/soap/SOAPHandlerInterceptor.java    | 67 ++++++++++----------
 1 file changed, 34 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/5958e971/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 db6f55f..7dfb3d4 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
@@ -138,7 +138,7 @@ public class SOAPHandlerInterceptor extends
                 message.getInterceptorChain().abort();
                 if (ep.getInFaultObserver() != null) {
                     ep.getInFaultObserver().onMessage(message);
-                    
+
                 }
             }
         }
@@ -157,12 +157,12 @@ public class SOAPHandlerInterceptor extends
     }
 
     private boolean handleMessageInternal(SoapMessage message) {
-        
+
         MessageContext context = createProtocolMessageContext(message);
         if (context == null) {
             return true;
         }
-                
+
         HandlerChainInvoker invoker = getInvoker(message);
         invoker.setProtocolMessageContext(context);
 
@@ -185,7 +185,7 @@ public class SOAPHandlerInterceptor extends
             // client side outbound
             if (getInvoker(message).isOutbound()) {
                 message.getInterceptorChain().abort();
-                
+
                 MessageObserver observer = message.getExchange().get(MessageObserver.class);
                 if (!message.getExchange().isOneWay()
                     && observer != null) {
@@ -193,7 +193,7 @@ public class SOAPHandlerInterceptor extends
                     Message responseMsg = new MessageImpl();
                     responseMsg.setExchange(message.getExchange());
                     responseMsg = e.getBinding().createMessage(responseMsg);
-    
+
                     // the request message becomes the response message
                     message.getExchange().setInMessage(responseMsg);
                     SOAPMessage soapMessage = ((SOAPMessageContext)context).getMessage();
@@ -237,7 +237,7 @@ public class SOAPHandlerInterceptor extends
                     // well for outbound case, as many outbound interceptors
                     // have their ending interceptors.
                     // For example, we can not skip MessageSenderInterceptor.
-                    chain.doInterceptStartingAfter(responseMsg, 
+                    chain.doInterceptStartingAfter(responseMsg,
                                                    SoapPreProtocolOutInterceptor.class.getName());
                 }
 
@@ -251,39 +251,40 @@ public class SOAPHandlerInterceptor extends
     @Override
     protected MessageContext createProtocolMessageContext(SoapMessage message) {
         SOAPMessageContextImpl sm = new SOAPMessageContextImpl(message);
-        
+
         Exchange exch = message.getExchange();
         setupBindingOperationInfo(exch, sm);
         SOAPMessage msg = sm.getMessage();
-        try {            
-            List<SOAPElement> params = new ArrayList<SOAPElement>();
-            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<SOAPElement>();
+                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;
     }
 
@@ -310,11 +311,11 @@ public class SOAPHandlerInterceptor extends
         if (getInvoker(message).getProtocolHandlers().isEmpty()) {
             return;
         }
-        if (getInvoker(message).isOutbound() 
+        if (getInvoker(message).isOutbound()
             && !chainAlreadyContainsSAAJ(message)) {
             SAAJ_OUT.handleFault(message);
         }
-    }    
+    }
 
     protected QName getOpQName(Exchange ex, Object data) {
         SOAPMessageContextImpl sm = (SOAPMessageContextImpl)data;


Mime
View raw message