You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2021/02/19 19:25:33 UTC

[activemq-artemis] branch master updated: ARTEMIS-3121 Avoid creation of unnecessary StringBuilder instance in Netty#getProtocols() and simplify implementation

This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/master by this push:
     new f9e23de  ARTEMIS-3121 Avoid creation of unnecessary StringBuilder instance in Netty#getProtocols() and simplify implementation
     new 8611095  This closes #3455
f9e23de is described below

commit f9e23def8d34ea2bbba2c0a77087f7c101960017
Author: sebthom <se...@users.noreply.github.com>
AuthorDate: Tue Feb 16 18:36:11 2021 +0100

    ARTEMIS-3121 Avoid creation of unnecessary StringBuilder instance in
    Netty#getProtocols() and simplify implementation
---
 .../artemis/core/remoting/impl/netty/NettyAcceptor.java  | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
index 089dcca..ff10893 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
@@ -862,18 +862,12 @@ public class NettyAcceptor extends AbstractAcceptor {
       return this;
    }
 
-   private static String getProtocols(Map<String, ProtocolManager> protocolManager) {
-      StringBuilder sb = new StringBuilder();
-      if (protocolManager != null) {
-         Set<String> strings = protocolManager.keySet();
-         for (String string : strings) {
-            if (sb.length() > 0) {
-               sb.append(",");
-            }
-            sb.append(string);
-         }
+   private static String getProtocols(final Map<String, ProtocolManager> protocolManagers) {
+      if (protocolManagers == null || protocolManagers.isEmpty()) {
+         return "";
       }
-      return sb.toString();
+
+      return String.join(",", protocolManagers.keySet());
    }
 
    // Inner classes -----------------------------------------------------------------------------