activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-5959
Date Tue, 08 Sep 2015 14:07:30 GMT
Repository: activemq
Updated Branches:
  refs/heads/activemq-5.12.x 3ffbaf9d8 -> f5b83cbc8


https://issues.apache.org/jira/browse/AMQ-5959

Add check to avoid NPE
(cherry picked from commit f58683ea07c49aa567a3dc888b12b7de92918ed6)


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

Branch: refs/heads/activemq-5.12.x
Commit: f5b83cbc8f162eb0ff09aee2d78486f766d8e50b
Parents: 3ffbaf9
Author: Timothy Bish <tabish121@gmail.com>
Authored: Tue Sep 8 10:03:23 2015 -0400
Committer: Timothy Bish <tabish121@gmail.com>
Committed: Tue Sep 8 10:07:24 2015 -0400

----------------------------------------------------------------------
 .../apache/activemq/broker/jmx/DestinationView.java    | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/f5b83cbc/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/DestinationView.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/DestinationView.java
b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/DestinationView.java
index 1fb7c76..f701ebc 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/DestinationView.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/DestinationView.java
@@ -24,6 +24,7 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 
 import javax.jms.Connection;
 import javax.jms.InvalidSelectorException;
@@ -355,15 +356,14 @@ public class DestinationView implements DestinationViewMBean {
         ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(brokerUrl);
         Connection connection = null;
         try {
-
             connection = cf.createConnection(userName, password);
             Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
             MessageProducer producer = session.createProducer(dest);
             ActiveMQTextMessage msg = (ActiveMQTextMessage) session.createTextMessage(body);
 
-            for (Iterator iter = headers.entrySet().iterator(); iter.hasNext();) {
-                Map.Entry entry = (Map.Entry) iter.next();
-                msg.setObjectProperty((String) entry.getKey(), entry.getValue());
+            for (Iterator<Entry<String, String>> iter = headers.entrySet().iterator();
iter.hasNext();) {
+                Entry<String, String> entry = iter.next();
+                msg.setObjectProperty(entry.getKey(), entry.getValue());
             }
 
             producer.setDeliveryMode(msg.getJMSDeliveryMode());
@@ -383,9 +383,10 @@ public class DestinationView implements DestinationViewMBean {
             return msg.getJMSMessageID();
 
         } finally {
-            connection.close();
+            if (connection != null) {
+                connection.close();
+            }
         }
-
     }
 
     @Override


Mime
View raw message