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/02 02:11:58 UTC

[incubator-eventmesh] branch master updated: [Enhancement] Use 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 14e792a5 [Enhancement] Use try-with-resources to manage resources
     new 6759c0a7 Merge pull request #2058 from Dlalran/master
14e792a5 is described below

commit 14e792a5fed7b57da4de250f16a5ec76d1cdc80d
Author: Dlalran <60...@qq.com>
AuthorDate: Tue Nov 1 16:06:45 2022 +0800

    [Enhancement] Use try-with-resources to manage resources
---
 .../runtime/admin/handler/RejectClientByIpPortHandler.java    | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RejectClientByIpPortHandler.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RejectClientByIpPortHandler.java
index 57a3ab66..44621f22 100644
--- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RejectClientByIpPortHandler.java
+++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RejectClientByIpPortHandler.java
@@ -54,8 +54,7 @@ public class RejectClientByIpPortHandler implements HttpHandler {
     @Override
     public void handle(HttpExchange httpExchange) throws IOException {
         String result = "";
-        OutputStream out = httpExchange.getResponseBody();
-        try {
+        try (OutputStream out = httpExchange.getResponseBody()) {
             String queryString = httpExchange.getRequestURI().getQuery();
             Map<String, String> queryStringInfo = NetUtils.formData2Dic(queryString);
             String ip = queryStringInfo.get(EventMeshConstants.MANAGE_IP);
@@ -98,14 +97,6 @@ public class RejectClientByIpPortHandler implements HttpHandler {
             out.write(result.getBytes(Constants.DEFAULT_CHARSET));
         } catch (Exception e) {
             logger.error("rejectClientByIpPort 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