camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [2/2] git commit: CAMEL-7449 Avoiding the NPE when using camel-jms with other JMS breaker
Date Thu, 22 May 2014 03:34:07 GMT
CAMEL-7449 Avoiding the NPE when using camel-jms with other JMS breaker

Conflicts:
	components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java


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

Branch: refs/heads/camel-2.12.x
Commit: c17b1dd14324e35ccfae8d0579dd51009eb3cc37
Parents: 68db8a2
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:20:18 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/c17b1dd1/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 b86e362..ad51e74 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
@@ -169,8 +169,8 @@ public class JmsBinding {
                 map.put("JMSType", JmsMessageHelper.getJMSType(jmsMessage));
 
                 // this works around a bug in the ActiveMQ property handling
-                map.put("JMSXGroupID", jmsMessage.getStringProperty("JMSXGroupID"));
-                map.put("JMSXUserID", jmsMessage.getStringProperty("JMSXUserID"));
+                map.put("JMSXGroupID", JmsMessageHelper.getStringProperty(jmsMessage, "JMSXGroupID"));
+                map.put("JMSXUserID", JmsMessageHelper.getStringProperty(jmsMessage, "JMSXUserID"));
             } catch (JMSException e) {
                 throw new RuntimeCamelException(e);
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/c17b1dd1/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