You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eventmesh.apache.org by ch...@apache.org on 2022/10/23 11:36:55 UTC
[incubator-eventmesh] branch master updated: [Enhancement] Use stringbuilder to build response
This is an automated email from the ASF dual-hosted git repository.
chenguangsheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-eventmesh.git
The following commit(s) were added to refs/heads/master by this push:
new 73df1906 [Enhancement] Use stringbuilder to build response
new fe1a0e9f Merge pull request #1766 from MaheshGPai/mahesh_pr
73df1906 is described below
commit 73df1906d095680b6a46174e88ac9ebc89981b27
Author: Mahesh G Pai <ma...@gmail.com>
AuthorDate: Sun Oct 23 12:55:00 2022 +0530
[Enhancement] Use stringbuilder to build response
---
.../runtime/admin/handler/ShowListenClientByTopicHandler.java | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/ShowListenClientByTopicHandler.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/ShowListenClientByTopicHandler.java
index 7b2bb14b..e1434f85 100644
--- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/ShowListenClientByTopicHandler.java
+++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/ShowListenClientByTopicHandler.java
@@ -53,7 +53,7 @@ public class ShowListenClientByTopicHandler implements HttpHandler {
@Override
public void handle(HttpExchange httpExchange) throws IOException {
- String result = "";
+ StringBuilder result = new StringBuilder();
OutputStream out = httpExchange.getResponseBody();
try {
String queryString = httpExchange.getRequestURI().getQuery();
@@ -68,17 +68,18 @@ public class ShowListenClientByTopicHandler implements HttpHandler {
for (ClientGroupWrapper cgw : clientGroupMap.values()) {
Set<Session> listenSessionSet = cgw.getTopic2sessionInGroupMapping().get(topic);
if (listenSessionSet != null && listenSessionSet.size() > 0) {
- result += String.format("group:%s", cgw.getGroup()) + newLine;
+ result.append(String.format("group:%s", cgw.getGroup())).append(newLine);
for (Session session : listenSessionSet) {
UserAgent userAgent = session.getClient();
- result += String.format("pid=%s | ip=%s | port=%s | path=%s | version=%s", userAgent.getPid(), userAgent
- .getHost(), userAgent.getPort(), userAgent.getPath(), userAgent.getVersion()) + newLine;
+ result.append(String.format("pid=%s | ip=%s | port=%s | path=%s | version=%s", userAgent.getPid(), userAgent
+ .getHost(), userAgent.getPort(), userAgent.getPath(), userAgent.getVersion()))
+ .append(newLine);
}
}
}
}
httpExchange.sendResponseHeaders(200, 0);
- out.write(result.getBytes(Constants.DEFAULT_CHARSET));
+ out.write(result.toString().getBytes(Constants.DEFAULT_CHARSET));
} catch (Exception e) {
logger.error("ShowListenClientByTopicHandler fail...", e);
} finally {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: commits-help@eventmesh.apache.org