walterlife commented on code in PR #2554:
URL: 
https://github.com/apache/incubator-eventmesh/pull/2554#discussion_r1045194603


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/ShowClientBySystemHandler.java:
##########
@@ -58,38 +58,33 @@ public ShowClientBySystemHandler(EventMeshTCPServer 
eventMeshTCPServer, HttpHand
      */
     @Override
     public void handle(HttpExchange httpExchange) throws IOException {
-        String result = "";
-        OutputStream out = httpExchange.getResponseBody();
-        try {
+        StringBuffer result = new StringBuffer();
+        try (OutputStream out = httpExchange.getResponseBody()) {
             String queryString = httpExchange.getRequestURI().getQuery();
             Map<String, String> queryStringInfo = 
NetUtils.formData2Dic(queryString);
             String subSystem = 
queryStringInfo.get(EventMeshConstants.MANAGE_SUBSYSTEM);
 
             String newLine = System.getProperty("line.separator");
-            logger.info("showClientBySubsys,subsys:{}=================", 
subSystem);
+            if (LOGGER.isInfoEnabled()) {
+                LOGGER.info("showClientBySubsys,subsys:{}", subSystem);
+            }
             ClientSessionGroupMapping clientSessionGroupMapping = 
eventMeshTCPServer.getClientSessionGroupMapping();
             ConcurrentHashMap<InetSocketAddress, Session> sessionMap = 
clientSessionGroupMapping.getSessionMap();
-            if (!sessionMap.isEmpty()) {
+            if (sessionMap != null && !sessionMap.isEmpty()) {
                 for (Session session : sessionMap.values()) {
                     if (session.getClient().getSubsystem().equals(subSystem)) {
                         UserAgent userAgent = session.getClient();
-                        result += String.format("pid=%s | ip=%s | port=%s | 
path=%s | purpose=%s", userAgent.getPid(), userAgent
-                                .getHost(), userAgent.getPort(), 
userAgent.getPath(), userAgent.getPurpose()) + newLine;
+                        result.append(String.format("pid=%s | ip=%s | port=%s 
| path=%s | purpose=%s",
+                                        userAgent.getPid(), 
userAgent.getHost(), userAgent.getPort(),
+                                        userAgent.getPath(), 
userAgent.getPurpose()))
+                                .append(newLine);
                     }
                 }
             }
             NetUtils.sendSuccessResponseHeaders(httpExchange);
-            out.write(result.getBytes(Constants.DEFAULT_CHARSET));
+            out.write(result.toString().getBytes(Constants.DEFAULT_CHARSET));
         } catch (Exception e) {
-            logger.error("ShowClientBySystemAndHandler fail...", e);
-        } finally {
-            if (out != null) {
-                try {
-                    out.close();
-                } catch (IOException e) {
-                    logger.warn("out close failed...", e);
-                }
-            }
+            LOGGER.error("ShowClientBySystemAndHandler fail...", e);

Review Comment:
   ....what does it mean. It is recommended that the error message should be a 
complete sentence, and express the exception message in as much detail as 
possible.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to