From ab9a40163c8ceaadacf812a4ed71d34be62d90a2 Mon Sep 17 00:00:00 2001 From: ChineseTony Date: Thu, 14 Mar 2024 16:03:21 +0800 Subject: [PATCH] [ISSUE #7904] use string builder to concat string --- .../common/namesrv/DefaultTopAddressing.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/common/src/main/java/org/apache/rocketmq/common/namesrv/DefaultTopAddressing.java b/common/src/main/java/org/apache/rocketmq/common/namesrv/DefaultTopAddressing.java index 179e200ae91..0636e30564a 100644 --- a/common/src/main/java/org/apache/rocketmq/common/namesrv/DefaultTopAddressing.java +++ b/common/src/main/java/org/apache/rocketmq/common/namesrv/DefaultTopAddressing.java @@ -107,27 +107,27 @@ public void registerChangeCallBack(NameServerUpdateCallback changeCallBack) { } public final String fetchNSAddr(boolean verbose, long timeoutMills) { - String url = this.wsAddr; + StringBuilder url = new StringBuilder(this.wsAddr); try { if (null != para && para.size() > 0) { if (!UtilAll.isBlank(this.unitName)) { - url = url + "-" + this.unitName + "?nofix=1&"; + url.append("-").append(this.unitName).append("?nofix=1&"); } else { - url = url + "?"; + url.append("?"); } for (Map.Entry entry : this.para.entrySet()) { - url += entry.getKey() + "=" + entry.getValue() + "&"; + url.append(entry.getKey()).append("=").append(entry.getValue()).append("&"); } - url = url.substring(0, url.length() - 1); + url = new StringBuilder(url.substring(0, url.length() - 1)); } else { if (!UtilAll.isBlank(this.unitName)) { - url = url + "-" + this.unitName + "?nofix=1"; + url.append("-").append(this.unitName).append("?nofix=1"); } } - HttpTinyClient.HttpResult result = HttpTinyClient.httpGet(url, null, null, "UTF-8", timeoutMills); + HttpTinyClient.HttpResult result = HttpTinyClient.httpGet(url.toString(), null, null, "UTF-8", timeoutMills); if (200 == result.code) { String responseStr = result.content; if (responseStr != null) {