camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/2] camel git commit: CAMEL-9248: Fixed potential NPE if JMSDestination is null, such as on WMQ
Date Sat, 24 Oct 2015 08:00:18 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.16.x fe9b4d5eb -> f204adb34
  refs/heads/master 7c9c4fce9 -> 880c31cd1


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/880c31cd
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/880c31cd
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/880c31cd

Branch: refs/heads/master
Commit: 880c31cd1ce9fd5fa019c3c07ae2ea86db3941c6
Parents: 7c9c4fc
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Sat Oct 24 09:25:45 2015 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sat Oct 24 09:25:45 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/880c31cd/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/880c31cd/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


Mime
View raw message