camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject git commit: CAMEL-7449 Avoiding the NPE when using camel-jms with other JMS breaker
Date Thu, 22 May 2014 03:11:23 GMT
Repository: camel
Updated Branches:
  refs/heads/master eca064d25 -> 5ab32ac3f


CAMEL-7449 Avoiding the NPE when using camel-jms with other JMS breaker


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

Branch: refs/heads/master
Commit: 5ab32ac3f7aba4eeaf82efb06cc5f01efe0fe0c7
Parents: eca064d
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Thu May 22 11:10:53 2014 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Thu May 22 11:10:53 2014 +0800

----------------------------------------------------------------------
 .../org/apache/camel/component/jms/JmsBinding.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/5ab32ac3/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
index 3a2f3e1..84b20a2 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
@@ -170,8 +170,8 @@ public class JmsBinding {
                 map.put("JMSType", JmsMessageHelper.getJMSType(jmsMessage));
 
                 // this works around a bug in the ActiveMQ property handling
-                map.put(JMS_X_GROUP_ID, jmsMessage.getStringProperty(JMS_X_GROUP_ID));
-                map.put("JMSXUserID", jmsMessage.getStringProperty("JMSXUserID"));
+                map.put(JMS_X_GROUP_ID, JmsMessageHelper.getStringProperty(jmsMessage, JMS_X_GROUP_ID));
+                map.put("JMSXUserID", JmsMessageHelper.getStringProperty(jmsMessage, "JMSXUserID"));
             } catch (JMSException e) {
                 throw new RuntimeCamelException(e);
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/5ab32ac3/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 eb125b3..24b6dee 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
@@ -300,6 +300,22 @@ public final class JmsMessageHelper {
 
         return null;
     }
+    
+    /**
+     * Gets the String Properties from the message.
+     *
+     * @param message  the message
+     * @return the type, can be <tt>null</tt>
+     */
+    public static String getStringProperty(Message message, String propertyName) {
+        try {
+            return message.getStringProperty(propertyName);
+        } catch (Exception e) {
+            // ignore due some broker client does not support accessing StringProperty
+        }
+
+        return null;
+    }
 
     /**
      * Gets the JMSRedelivered from the message.


Mime
View raw message