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/eventmesh.git


The following commit(s) were added to refs/heads/master by this push:
     new 40de773cb [ISSUE #4017] Resources may not be released. (#4075)
40de773cb is described below

commit 40de773cb6096ac05ad8556d0448e8b04a837d98
Author: kyooosukedn <[email protected]>
AuthorDate: Wed Jun 14 04:26:32 2023 +0200

    [ISSUE #4017] Resources may not be released. (#4075)
    
    * used try-with-resources to manage resources
    
    * Corrected check style
---
 .../runtime/admin/utils/HttpExchangeUtils.java        | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git 
a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/utils/HttpExchangeUtils.java
 
b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/utils/HttpExchangeUtils.java
index 177b378bc..67479c8c2 100644
--- 
a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/utils/HttpExchangeUtils.java
+++ 
b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/utils/HttpExchangeUtils.java
@@ -26,17 +26,16 @@ import java.nio.charset.StandardCharsets;
 public class HttpExchangeUtils {
 
     public static String streamToString(InputStream stream) throws IOException 
{
-        InputStreamReader isr = new InputStreamReader(stream, 
StandardCharsets.UTF_8);
-        BufferedReader bufferedReader = new BufferedReader(isr);
+        try (BufferedReader bufferedReader = new BufferedReader(new 
InputStreamReader(stream, StandardCharsets.UTF_8))) {
 
-        int b;
-        StringBuilder buffer = new StringBuilder();
-        while ((b = bufferedReader.read()) != -1) {
-            buffer.append((char) b);
-        }
+            StringBuilder buffer = new StringBuilder();
+            int b;
+
+            while ((b = bufferedReader.read()) != -1) {
+                buffer.append((char) b);
+            }
 
-        bufferedReader.close();
-        isr.close();
-        return buffer.toString();
+            return buffer.toString();
+        }
     }
 }


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

Reply via email to