From 3ad8391e9b1cca64b1870f2d1038a644b2b57519 Mon Sep 17 00:00:00 2001 From: Sebastian Thomschke Date: Fri, 6 Dec 2019 11:55:48 +0100 Subject: [PATCH] ARTEMIS-2570 Improve performance of ConnectionsView --- .../artemis/core/management/impl/view/ConnectionView.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ConnectionView.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ConnectionView.java index 4ed0b4923e..0bf0017595 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ConnectionView.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ConnectionView.java @@ -70,13 +70,11 @@ public class ConnectionView extends ActiveMQAbstractView { .add("protocol", toString(connection.getProtocolName())) .add("clientID", toString(connection.getClientID() != null ? connection.getClientID() : jmsSessionClientID)) .add("localAddress", toString(connection.getTransportLocalAddress())) - .add("sessionCount", server.getSessions(connection.getID().toString()).size()); + .add("sessionCount", sessions.size()); } @Override public Object getField(RemotingConnection connection, String fieldName) { - List sessions = server.getSessions(connection.getID().toString()); - switch (fieldName) { case "connectionID": return connection.getID(); @@ -84,6 +82,7 @@ public class ConnectionView extends ActiveMQAbstractView { return connection.getRemoteAddress(); case "users": Set users = new TreeSet<>(); + List sessions = server.getSessions(connection.getID().toString()); for (ServerSession session : sessions) { String username = session.getUsername() == null ? "" : session.getUsername(); users.add(username); @@ -100,7 +99,7 @@ public class ConnectionView extends ActiveMQAbstractView { case "localAddress": return connection.getTransportLocalAddress(); case "sessionCount": - return sessions.size(); + return server.getSessions(connection.getID().toString()).size(); default: throw new IllegalArgumentException("Unsupported field, " + fieldName); }