You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eventmesh.apache.org by mi...@apache.org on 2022/11/09 13:50:22 UTC

[incubator-eventmesh] branch master updated: Change to try-with-resources to manage resources

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

mikexue 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 9d52cfdf Change to try-with-resources to manage resources
     new 6b2c0a93 Merge pull request #2141 from 1193324541/fix_patch_20221109
9d52cfdf is described below

commit 9d52cfdf9a53a5293ba9f6003bf280566a07ec7b
Author: 1193324541@qq.com <11...@qq.com>
AuthorDate: Wed Nov 9 12:44:00 2022 +0800

    Change to try-with-resources to manage resources
---
 .../admin/handler/ShowListenClientByTopicHandler.java        | 12 +-----------
 1 file changed, 1 insertion(+), 11 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 e1434f85..0f79f473 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
@@ -54,8 +54,7 @@ public class ShowListenClientByTopicHandler implements HttpHandler {
     @Override
     public void handle(HttpExchange httpExchange) throws IOException {
         StringBuilder result = new StringBuilder();
-        OutputStream out = httpExchange.getResponseBody();
-        try {
+        try(OutputStream out = httpExchange.getResponseBody();) {
             String queryString = httpExchange.getRequestURI().getQuery();
             Map<String, String> queryStringInfo = NetUtils.formData2Dic(queryString);
             String topic = queryStringInfo.get(EventMeshConstants.MANAGE_TOPIC);
@@ -82,15 +81,6 @@ public class ShowListenClientByTopicHandler implements HttpHandler {
             out.write(result.toString().getBytes(Constants.DEFAULT_CHARSET));
         } catch (Exception e) {
             logger.error("ShowListenClientByTopicHandler fail...", e);
-        } finally {
-            if (out != null) {
-                try {
-                    out.close();
-                } catch (IOException e) {
-                    logger.warn("out close failed...", e);
-                }
-            }
         }
-
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: commits-help@eventmesh.apache.org