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 120610cc08..bca646cbc3 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(), 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 10b8ba0262..63fcdcd573 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)); 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 f3ac38c6d4..2e84fc48ec 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 sessions = server.getActiveMQServer().getSessions(connectionID); - JsonArray jsonSessions = toJsonArray(sessions); - array.add(jsonSessions); + for (ServerSession session : sessions) { + Set consumers = session.getServerConsumers(); + for (ServerConsumer consumer : consumers) { + JsonObject obj = toJSONObject(consumer); + if (obj != null) { + array.add(obj); + } + } + } } } return array.build().toString(); 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 3a60bfa326..733293d7d8 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); } }