camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [3/6] camel git commit: CAMEL-11772 - Fix potential ClassCastException when creating the message ID in camel-sjms and camel-jms
Date Wed, 13 Sep 2017 07:47:25 GMT
CAMEL-11772 - Fix potential ClassCastException when creating the message ID in camel-sjms and
camel-jms


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

Branch: refs/heads/camel-2.19.x
Commit: 25a04277386a3782f120a304164bc79033200c4f
Parents: 6575f14
Author: derekwilhelm <derek.wilhelm@connexta.com>
Authored: Tue Sep 12 08:19:06 2017 -0600
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Wed Sep 13 09:46:42 2017 +0200

----------------------------------------------------------------------
 .../java/org/apache/camel/component/jms/JmsMessage.java | 12 +++++++++---
 .../org/apache/camel/component/sjms/SjmsMessage.java    | 12 +++++++++---
 2 files changed, 18 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/25a04277/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java
b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java
index 0408ff7..2a757a0 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java
@@ -235,7 +235,13 @@ public class JmsMessage extends DefaultMessage {
             return super.createMessageId();
         }
         try {
-            String id = getDestinationAsString(jmsMessage.getJMSDestination()) + jmsMessage.getJMSMessageID();
+            String id = getDestinationAsString(jmsMessage.getJMSDestination());
+            if(id != null) {
+                id += jmsMessage.getJMSMessageID();
+            }
+            else {
+                id = super.createMessageId();
+            }
             return getSanitizedString(id);
         } catch (JMSException e) {
             throw new RuntimeExchangeException("Unable to retrieve JMSMessageID from JMS
Message", getExchange(), e);
@@ -252,12 +258,12 @@ public class JmsMessage extends DefaultMessage {
     }
 
     private String getDestinationAsString(Destination destination) throws JMSException {
-        String result;
+        String result = null;
         if (destination == null) {
             result = "null destination!" + File.separator;
         } else if (destination instanceof Topic) {
             result = "topic" + File.separator + ((Topic) destination).getTopicName() + File.separator;
-        } else {
+        } else if (destination instanceof Queue){
             result = "queue" + File.separator + ((Queue) destination).getQueueName() + File.separator;
         }
         return result;

http://git-wip-us.apache.org/repos/asf/camel/blob/25a04277/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/SjmsMessage.java
----------------------------------------------------------------------
diff --git a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/SjmsMessage.java
b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/SjmsMessage.java
index 907985e..4cc83ce 100644
--- a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/SjmsMessage.java
+++ b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/SjmsMessage.java
@@ -248,7 +248,13 @@ public class SjmsMessage extends DefaultMessage {
             return super.createMessageId();
         }
         try {
-            String id = getDestinationAsString(jmsMessage.getJMSDestination()) + jmsMessage.getJMSMessageID();
+            String id = getDestinationAsString(jmsMessage.getJMSDestination());
+            if(id != null) {
+                id += jmsMessage.getJMSMessageID();
+            }
+            else {
+                id = super.createMessageId();
+            }
             return getSanitizedString(id);
         } catch (JMSException e) {
             throw new RuntimeExchangeException("Unable to retrieve JMSMessageID from JMS
Message", getExchange(), e);
@@ -265,12 +271,12 @@ public class SjmsMessage extends DefaultMessage {
     }
 
     private String getDestinationAsString(Destination destination) throws JMSException {
-        String result;
+        String result = null;
         if (destination == null) {
             result = "null destination!" + File.separator;
         } else if (destination instanceof Topic) {
             result = "topic" + File.separator + ((Topic) destination).getTopicName() + File.separator;
-        } else {
+        } else if (destination instanceof Queue) {
             result = "queue" + File.separator + ((Queue) destination).getQueueName() + File.separator;
         }
         return result;


Mime
View raw message