camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From si...@apache.org
Subject camel git commit: CAMEL-11486: NullPointerException for invalid payload with session handling enabled
Date Fri, 30 Jun 2017 11:01:54 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.19.x 961d4f693 -> f54374616


CAMEL-11486: NullPointerException for invalid payload with session handling enabled

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

Branch: refs/heads/camel-2.19.x
Commit: f5437461624eaec3e9e2d05c6684975723ab302e
Parents: 961d4f6
Author: Stephan Siano <stephan.siano@sap.com>
Authored: Fri Jun 30 12:52:39 2017 +0200
Committer: Stephan Siano <stephan.siano@sap.com>
Committed: Fri Jun 30 13:01:22 2017 +0200

----------------------------------------------------------------------
 .../org/apache/camel/component/cxf/CxfProducer.java  |  7 +++++--
 .../camel/component/cxf/CxfProducerSessionTest.java  | 15 +++++++++++++++
 2 files changed, 20 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/f5437461/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
index dcd92d8..cf0e37b 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
@@ -176,8 +176,11 @@ public class CxfProducer extends DefaultProducer implements AsyncProcessor
{
             // add cookies to the cookie store
             if (endpoint.getCookieHandler() != null) {
                 try {
-                    Map<String, List<String>> cxfHeaders = CastUtils.cast((Map<?,
?>)cxfExchange.getInMessage().get(Message.PROTOCOL_HEADERS));
-                    endpoint.getCookieHandler().storeCookies(camelExchange, endpoint.getRequestUri(camelExchange),
cxfHeaders);
+                    Message inMessage = cxfExchange.getInMessage();
+                    if (inMessage != null) {
+                        Map<String, List<String>> cxfHeaders = CastUtils.cast((Map<?,
?>)inMessage.get(Message.PROTOCOL_HEADERS));
+                        endpoint.getCookieHandler().storeCookies(camelExchange, endpoint.getRequestUri(camelExchange),
cxfHeaders);
+                    }
                 } catch (IOException e) {
                     LOG.error("Cannot store cookies", e);
                 }

http://git-wip-us.apache.org/repos/asf/camel/blob/f5437461/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerSessionTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerSessionTest.java
b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerSessionTest.java
index 86ecd2f..104194b 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerSessionTest.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerSessionTest.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.cxf;
 import java.util.Collections;
 import java.util.Map;
 
+import org.apache.camel.CamelExecutionException;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.http.common.cookie.ExchangeCookieHandler;
 import org.apache.camel.http.common.cookie.InstanceCookieHandler;
@@ -101,6 +102,18 @@ public class CxfProducerSessionTest extends CamelTestSupport {
         assertMockEndpointsSatisfied();
     }
 
+    @Test(expected = IllegalArgumentException.class)
+    public void testSessionWithInvalidPayload() throws Throwable {
+        try {
+            template.requestBody("direct:invalid", "World", String.class);
+        } catch (CamelExecutionException e) {
+            if (e.getCause() != null) {
+                throw e.getCause();
+            }
+            throw e;
+        }
+    }
+
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
@@ -128,6 +141,8 @@ public class CxfProducerSessionTest extends CamelTestSupport {
                     .to(url + "&cookieHandler=#exchangeCookieHandler")
                     .setBody().xpath(PARAMETER_XPATH, String.class, NAMESPACES)
                     .to("mock:result");
+                from("direct:invalid")
+                    .to(url + "&cookieHandler=#exchangeCookieHandler");
             }
         };
     }


Mime
View raw message