camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lburgazz...@apache.org
Subject [1/2] camel git commit: [CAMEL-11093] NPE when defaultValueProvider not given
Date Fri, 31 Mar 2017 07:56:28 GMT
Repository: camel
Updated Branches:
  refs/heads/master c54509df5 -> 28a156753


[CAMEL-11093] NPE when defaultValueProvider not given


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

Branch: refs/heads/master
Commit: fb742406c6083f31c1098d487531556618262cdc
Parents: c54509d
Author: Thomas Diesler <thomas.diesler@jboss.com>
Authored: Thu Mar 30 12:58:46 2017 +0200
Committer: lburgazzoli <lburgazzoli@gmail.com>
Committed: Fri Mar 31 09:39:24 2017 +0200

----------------------------------------------------------------------
 .../src/main/java/org/apache/camel/impl/DefaultMessage.java    | 6 ++++++
 .../org/apache/camel/component/rabbitmq/RabbitMQProducer.java  | 4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/fb742406/camel-core/src/main/java/org/apache/camel/impl/DefaultMessage.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultMessage.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultMessage.java
index 1e49766..57bedfa 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultMessage.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultMessage.java
@@ -28,6 +28,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.util.AttachmentMap;
 import org.apache.camel.util.CaseInsensitiveMap;
 import org.apache.camel.util.EndpointHelper;
+import org.apache.camel.util.ObjectHelper;
 
 /**
  * The default implementation of {@link org.apache.camel.Message}
@@ -67,6 +68,8 @@ public class DefaultMessage extends MessageSupport {
     }
 
     public Object getHeader(String name, Supplier<Object> defaultValueSupplier) {
+        ObjectHelper.notNull(name, "name");
+        ObjectHelper.notNull(defaultValueSupplier, "defaultValueSupplier");
         Object answer = getHeaders().get(name);
         return answer != null ? answer : defaultValueSupplier.get();
     }
@@ -123,6 +126,9 @@ public class DefaultMessage extends MessageSupport {
 
     @SuppressWarnings("unchecked")
     public <T> T getHeader(String name, Supplier<Object> defaultValueSupplier,
Class<T> type) {
+        ObjectHelper.notNull(name, "name");
+        ObjectHelper.notNull(type, "type");
+        ObjectHelper.notNull(defaultValueSupplier, "defaultValueSupplier");
         Object value = getHeader(name, defaultValueSupplier);
         if (value == null) {
             // lets avoid NullPointerException when converting to boolean for null values

http://git-wip-us.apache.org/repos/asf/camel/blob/fb742406/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQProducer.java
b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQProducer.java
index edefd6e..3e45c15 100644
--- a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQProducer.java
+++ b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQProducer.java
@@ -220,7 +220,7 @@ public class RabbitMQProducer extends DefaultAsyncProducer {
             exchangeName = getEndpoint().getExchangeName();
         }
 
-        String key = in.getHeader(RabbitMQConstants.ROUTING_KEY, null, String.class);
+        String key = in.getHeader(RabbitMQConstants.ROUTING_KEY, String.class);
         // we just need to make sure RoutingKey option take effect if it is not BridgeEndpoint
         if (key == null || getEndpoint().isBridgeEndpoint()) {
             key = getEndpoint().getRoutingKey() == null ? "" : getEndpoint().getRoutingKey();
@@ -245,7 +245,7 @@ public class RabbitMQProducer extends DefaultAsyncProducer {
     private boolean processInOnly(Exchange exchange, AsyncCallback callback) throws Exception
{
         String exchangeName = getEndpoint().getExchangeName(exchange.getIn());
 
-        String key = exchange.getIn().getHeader(RabbitMQConstants.ROUTING_KEY, null, String.class);
+        String key = exchange.getIn().getHeader(RabbitMQConstants.ROUTING_KEY, String.class);
         // we just need to make sure RoutingKey option take effect if it is not BridgeEndpoint
         if (key == null || getEndpoint().isBridgeEndpoint()) {
             key = getEndpoint().getRoutingKey() == null ? "" : getEndpoint().getRoutingKey();


Mime
View raw message