Skip to content

Commit

Permalink
[ISSUE apache#7904] use string builder to concat string
Browse files Browse the repository at this point in the history
  • Loading branch information
ChineseTony authored Mar 14, 2024
1 parent 6d47404 commit ab9a401
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> 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) {
Expand Down

0 comments on commit ab9a401

Please sign in to comment.