You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2015/10/24 10:00:19 UTC

[2/2] camel git commit: CAMEL-9248: Fixed potential NPE if JMSDestination is null, such as on WMQ

CAMEL-9248: Fixed potential NPE if JMSDestination is null, such as on WMQ


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

Branch: refs/heads/camel-2.16.x
Commit: f204adb34f70ab8f9969b89f54135b1e506d38f8
Parents: fe9b4d5
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Oct 24 09:25:45 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Oct 24 10:02:51 2015 +0200

----------------------------------------------------------------------
 .../component/jms/EndpointMessageListener.java      |  4 ++--
 .../camel/component/jms/JmsMessageHelper.java       | 16 ++++++++++++++++
 2 files changed, 18 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/f204adb3/components/camel-jms/src/main/java/org/apache/camel/component/jms/EndpointMessageListener.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/EndpointMessageListener.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/EndpointMessageListener.java
index b21b0a7..f3d48f4 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/EndpointMessageListener.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/EndpointMessageListener.java
@@ -78,8 +78,8 @@ public class EndpointMessageListener implements SessionAwareMessageListener {
             sendReply = replyDestination != null && !disableReplyTo;
 
             // we should also not send back reply to ourself if this destination and replyDestination is the same
-            Destination destination = message.getJMSDestination();
-            if (sendReply && !endpoint.isReplyToSameDestinationAllowed() && destination.equals(replyDestination)) {
+            Destination destination = JmsMessageHelper.getJMSDestination(message);
+            if (destination != null && sendReply && !endpoint.isReplyToSameDestinationAllowed() && destination.equals(replyDestination)) {
                 LOG.debug("JMSDestination and JMSReplyTo is the same, will skip sending a reply message to itself: {}", destination);
                 sendReply = false;
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/f204adb3/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessageHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessageHelper.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessageHelper.java
index 1b50d65..5788662 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessageHelper.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessageHelper.java
@@ -350,6 +350,22 @@ public final class JmsMessageHelper {
     }
 
     /**
+     * Gets the JMSDestination from the message.
+     *
+     * @param message  the message
+     * @return the JMSDestination, or <tt>null</tt> if not able to get
+     */
+    public static Destination getJMSDestination(Message message) {
+        try {
+            return message.getJMSDestination();
+        } catch (Exception e) {
+            // ignore if JMS broker do not support this
+        }
+
+        return null;
+    }
+
+    /**
      * Sets the JMSDeliveryMode on the message.
      *
      * @param exchange the exchange