camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject git commit: CAMEL-7069: Sending an empty soap body message to a generic provider camel-cxf consumer results in NPE
Date Wed, 29 Jan 2014 11:29:45 GMT
Updated Branches:
  refs/heads/master 8cd86620d -> 033f9dde0


CAMEL-7069: Sending an empty soap body message to a generic provider camel-cxf consumer results
in NPE


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/033f9dde
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/033f9dde
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/033f9dde

Branch: refs/heads/master
Commit: 033f9dde09ebcacd8863f33a97d2c06aa1035b4d
Parents: 8cd8662
Author: Akitoshi Yoshida <ay@apache.org>
Authored: Wed Jan 29 12:28:37 2014 +0100
Committer: Akitoshi Yoshida <ay@apache.org>
Committed: Wed Jan 29 12:28:55 2014 +0100

----------------------------------------------------------------------
 .../camel/component/cxf/DefaultCxfBinding.java  |  2 +-
 .../cxf/converter/CxfPayloadConverter.java      |  3 +--
 .../component/cxf/DefaultCxfBindingTest.java    | 24 ++++++++++++++++++++
 3 files changed, 26 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/033f9dde/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
index 346dd63..f311573 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
@@ -741,7 +741,7 @@ public class DefaultCxfBinding implements CxfBinding, HeaderFilterStrategyAware
         }
         MessageContentsList inObjects = MessageContentsList.getContentsList(message);
         if (inObjects == null) {
-            return null;
+            return new ArrayList<Source>(0);
         }
         org.apache.cxf.message.Exchange exchange = message.getExchange();
         BindingOperationInfo boi = exchange.getBindingOperationInfo();

http://git-wip-us.apache.org/repos/asf/camel/blob/033f9dde/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfPayloadConverter.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfPayloadConverter.java
b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfPayloadConverter.java
index a613e47..ff24d6c 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfPayloadConverter.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfPayloadConverter.java
@@ -170,8 +170,7 @@ public final class CxfPayloadConverter {
         if (CxfPayload.class.isAssignableFrom(value.getClass())) {
             CxfPayload<?> payload = (CxfPayload<?>) value;
             
-            if (payload.getBodySources() != null 
-                && payload.getBodySources().size() == 1) {
+            if (payload.getBodySources().size() == 1) {
                 if (type.isAssignableFrom(Document.class)) {
                     Source s = payload.getBodySources().get(0);
                     Document d;

http://git-wip-us.apache.org/repos/asf/camel/blob/033f9dde/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/DefaultCxfBindingTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/DefaultCxfBindingTest.java
b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/DefaultCxfBindingTest.java
index 525ec72..2faa63f 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/DefaultCxfBindingTest.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/DefaultCxfBindingTest.java
@@ -149,6 +149,30 @@ public class DefaultCxfBindingTest extends Assert {
     }
 
     @Test
+    public void testPopupalteExchangeFromCxfResponseOfNullBody() {
+        DefaultCxfBinding cxfBinding = new DefaultCxfBinding();
+        cxfBinding.setHeaderFilterStrategy(new DefaultHeaderFilterStrategy());
+        Exchange exchange = new DefaultExchange(context);
+        org.apache.cxf.message.Exchange cxfExchange = new org.apache.cxf.message.ExchangeImpl();
+        exchange.setProperty(CxfConstants.DATA_FORMAT_PROPERTY, DataFormat.PAYLOAD);
+        Map<String, Object> responseContext = new HashMap<String, Object>();
+        responseContext.put(org.apache.cxf.message.Message.RESPONSE_CODE, Integer.valueOf(200));
+        Map<String, List<String>> headers = new TreeMap<String, List<String>>(String.CASE_INSENSITIVE_ORDER);
+        responseContext.put(org.apache.cxf.message.Message.PROTOCOL_HEADERS, headers);
+        org.apache.cxf.message.Message cxfMessage = new org.apache.cxf.message.MessageImpl();
+        cxfExchange.setInMessage(cxfMessage);
+        
+        cxfBinding.populateExchangeFromCxfResponse(exchange, cxfExchange, responseContext);
+
+        CxfPayload<?> cxfPayload = exchange.getOut().getBody(CxfPayload.class);
+
+        assertNotNull(cxfPayload);
+        List<?> body = cxfPayload.getBody(); 
+        assertNotNull(body);
+        assertEquals(0, body.size());
+    }
+    
+    @Test
     public void testPopupalteCxfResponseFromExchange() {
         DefaultCxfBinding cxfBinding = new DefaultCxfBinding();
         cxfBinding.setHeaderFilterStrategy(new DefaultHeaderFilterStrategy());


Mime
View raw message