Repository: camel
Updated Branches:
  refs/heads/camel-2.18.x 312a5e70d -> 7d0dbdffb
  refs/heads/camel-2.19.x 6575f149e -> dc55037d8
  refs/heads/master a9c64d234 -> 16b7fbb5c


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

Branch: refs/heads/master
Commit: 46ef7a515a25cfdc6c6c8e86a562b37f1ac40983
Parents: a9c64d2
Author: derekwilhelm <[email protected]>
Authored: Tue Sep 12 08:19:06 2017 -0600
Committer: Claus Ibsen <[email protected]>
Committed: Wed Sep 13 09:28:09 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/46ef7a51/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 88428ec..3fe42f7 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
@@ -237,7 +237,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);
@@ -254,12 +260,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/46ef7a51/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 fa5b60b..3abdd93 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
@@ -250,7 +250,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);
@@ -267,12 +273,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;

Reply via email to