activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [2/2] activemq-artemis git commit: ARTEMIS-565 fix more broken Json stuff
Date Tue, 26 Jul 2016 18:34:36 GMT
ARTEMIS-565 fix more broken Json stuff


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

Branch: refs/heads/master
Commit: 1de4dbbe2739c171b20aa7a9e4528c23ae06adcf
Parents: 41d8749
Author: jbertram <jbertram@apache.org>
Authored: Tue Jul 26 11:11:07 2016 -0500
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Tue Jul 26 14:31:50 2016 -0400

----------------------------------------------------------------------
 .../api/jms/management/JMSConnectionInfo.java   |  4 +--
 .../api/jms/management/JMSConsumerInfo.java     |  2 +-
 .../management/impl/JMSServerControlImpl.java   | 30 ++++++++++++++------
 .../impl/ActiveMQServerControlImpl.java         |  6 +++-
 4 files changed, 29 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/1de4dbbe/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSConnectionInfo.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSConnectionInfo.java
b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSConnectionInfo.java
index 120610c..bca646c 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSConnectionInfo.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSConnectionInfo.java
@@ -40,8 +40,8 @@ public class JMSConnectionInfo {
       JMSConnectionInfo[] infos = new JMSConnectionInfo[array.size()];
       for (int i = 0; i < array.size(); i++) {
          JsonObject obj = array.getJsonObject(i);
-         String cid = obj.isNull("clientID") ? null : obj.getString("clientID");
-         String uname = obj.isNull("principal") ? null : obj.getString("principal");
+         String cid = obj.containsKey("clientID") ? obj.getString("clientID") : null;
+         String uname = obj.containsKey("principal") ? obj.getString("principal") : null;
 
          JMSConnectionInfo info = new JMSConnectionInfo(obj.getString("connectionID"), obj.getString("clientAddress"),
                obj.getJsonNumber("creationTime").longValue(),

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/1de4dbbe/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSConsumerInfo.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSConsumerInfo.java
b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSConsumerInfo.java
index 10b8ba0..63fcdcd 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSConsumerInfo.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSConsumerInfo.java
@@ -54,7 +54,7 @@ public class JMSConsumerInfo {
       JMSConsumerInfo[] infos = new JMSConsumerInfo[array.size()];
       for (int i = 0; i < array.size(); i++) {
          JsonObject sub = array.getJsonObject(i);
-         JMSConsumerInfo info = new JMSConsumerInfo(sub.getString("consumerID"), sub.getString("connectionID"),
+         JMSConsumerInfo info = new JMSConsumerInfo(sub.getJsonNumber("consumerID").toString(),
sub.getString("connectionID"),
                sub.getString("destinationName"), sub.getString("destinationType"), sub.getBoolean("browseOnly"),
                sub.getJsonNumber("creationTime").longValue(),
                sub.getBoolean("durable"), sub.getString("filter", null));

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/1de4dbbe/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSServerControlImpl.java
----------------------------------------------------------------------
diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSServerControlImpl.java
b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSServerControlImpl.java
index f3ac38c..2e84fc4 100644
--- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSServerControlImpl.java
+++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSServerControlImpl.java
@@ -620,15 +620,20 @@ public class JMSServerControlImpl extends AbstractControl implements
JMSServerCo
          for (RemotingConnection connection : connections) {
             ServerSession session = jmsSessions.get(connection.getID());
             if (session != null) {
-               JsonObject obj = Json.createObjectBuilder()
+               JsonObjectBuilder objectBuilder = Json.createObjectBuilder()
                   .add("connectionID", connection.getID().toString())
                   .add("clientAddress", connection.getRemoteAddress())
-                  .add("creationTime", connection.getCreationTime())
-                  // Notice: this will be null when the user haven't set the client-id
-                  .add("clientID", session.getMetaData(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY))
-                  .add("principal", session.getUsername())
-                  .build();
-               array.add(obj);
+                  .add("creationTime", connection.getCreationTime());
+
+               if (session.getMetaData(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY) != null)
{
+                  objectBuilder.add("clientID", session.getMetaData(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY));
+               }
+
+               if (session.getUsername() != null) {
+                  objectBuilder.add("principal", session.getUsername());
+               }
+
+               array.add(objectBuilder.build());
             }
          }
          return array.build().toString();
@@ -651,8 +656,15 @@ public class JMSServerControlImpl extends AbstractControl implements
JMSServerCo
          for (RemotingConnection connection : connections) {
             if (connectionID.equals(connection.getID().toString())) {
                List<ServerSession> sessions = server.getActiveMQServer().getSessions(connectionID);
-               JsonArray jsonSessions = toJsonArray(sessions);
-               array.add(jsonSessions);
+               for (ServerSession session : sessions) {
+                  Set<ServerConsumer> consumers = session.getServerConsumers();
+                  for (ServerConsumer consumer : consumers) {
+                     JsonObject obj = toJSONObject(consumer);
+                     if (obj != null) {
+                        array.add(obj);
+                     }
+                  }
+               }
             }
          }
          return array.build().toString();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/1de4dbbe/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
index 3a60bfa..733293d 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
@@ -1398,8 +1398,12 @@ public class ActiveMQServerControlImpl extends AbstractControl implements
Active
             JsonObjectBuilder obj = Json.createObjectBuilder()
                .add("sessionID", sess.getName())
                .add("creationTime", sess.getCreationTime())
-               .add("principal", sess.getValidatedUser())
                .add("consumerCount", sess.getServerConsumers().size());
+
+            if (sess.getValidatedUser() != null) {
+               obj.add("principal", sess.getValidatedUser());
+            }
+
             array.add(obj);
          }
       }


Mime
View raw message