Repository: camel
Updated Branches:
  refs/heads/master 8576a1fea -> e896fe520


CAMEL-7589: fix NPE


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

Branch: refs/heads/master
Commit: de13f934ecb300a93d3fc311fbb2f1de50343400
Parents: fc4cbdb
Author: wuwen <wuwen...@gmail.com>
Authored: Mon Aug 18 00:07:06 2014 +0800
Committer: wuwen <wuwen...@gmail.com>
Committed: Mon Aug 18 00:07:06 2014 +0800

----------------------------------------------------------------------
 .../org/apache/camel/impl/DefaultProducerTemplate.java  | 12 ++++++++----
 .../apache/camel/impl/DefaultProducerTemplateTest.java  |  3 +++
 2 files changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/de13f934/camel-core/src/main/java/org/apache/camel/impl/DefaultProducerTemplate.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/impl/DefaultProducerTemplate.java 
b/camel-core/src/main/java/org/apache/camel/impl/DefaultProducerTemplate.java
index 7f852f7..6a7cfd4 100644
--- 
a/camel-core/src/main/java/org/apache/camel/impl/DefaultProducerTemplate.java
+++ 
b/camel-core/src/main/java/org/apache/camel/impl/DefaultProducerTemplate.java
@@ -233,8 +233,10 @@ public class DefaultProducerTemplate extends 
ServiceSupport implements ProducerT
         Exchange result = send(endpoint, new Processor() {
             public void process(Exchange exchange) {
                 Message in = exchange.getIn();
-                for (Map.Entry<String, Object> header : headers.entrySet()) {
-                    in.setHeader(header.getKey(), header.getValue());
+                if (headers != null) {
+                    for (Map.Entry<String, Object> header : 
headers.entrySet()) {
+                        in.setHeader(header.getKey(), header.getValue());
+                    }
                 }
                 in.setBody(body);
             }
@@ -251,8 +253,10 @@ public class DefaultProducerTemplate extends 
ServiceSupport implements ProducerT
         Exchange exchange = send(endpoint, pattern, new Processor() {
             public void process(Exchange exchange) throws Exception {
                 Message in = exchange.getIn();
-                for (Map.Entry<String, Object> header : headers.entrySet()) {
-                    in.setHeader(header.getKey(), header.getValue());
+                if (headers != null) {
+                    for (Map.Entry<String, Object> header : 
headers.entrySet()) {
+                        in.setHeader(header.getKey(), header.getValue());
+                    }
                 }
                 in.setBody(body);
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/de13f934/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateTest.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateTest.java
 
b/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateTest.java
index ab966eb..8e5942b 100644
--- 
a/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateTest.java
+++ 
b/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateTest.java
@@ -198,6 +198,9 @@ public class DefaultProducerTemplateTest extends 
ContextTestSupport {
         out = producer.requestBodyAndHeaders("Hello", headers);
         assertEquals("Bye Bye World", out);
 
+        out = producer.requestBodyAndHeaders("Hello", null);
+        assertEquals("Bye Bye World", out);
+
         producer.stop();
     }
 

Reply via email to