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 2023/06/14 02:26:39 UTC
[eventmesh] branch master updated: [ISSUE #4017] Resources may not be released. (#4075)
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 <87...@users.noreply.github.com>
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: commits-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: commits-help@eventmesh.apache.org