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

healchow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/inlong.git


The following commit(s) were added to refs/heads/master by this push:
     new 03024733f [INLONG-7548][Agent][Manager] Use try-with-resource to close 
resources (#7549)
03024733f is described below

commit 03024733fddf1499889994d48445ed030cbba83a
Author: TYzzt <[email protected]>
AuthorDate: Fri Mar 10 09:49:45 2023 +0800

    [INLONG-7548][Agent][Manager] Use try-with-resource to close resources 
(#7549)
---
 .../main/java/org/apache/inlong/agent/core/conf/ConfigJetty.java   | 1 +
 .../main/java/org/apache/inlong/manager/common/util/AESUtils.java  | 7 ++++---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git 
a/inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/conf/ConfigJetty.java
 
b/inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/conf/ConfigJetty.java
index e5b35148d..d29cecdb7 100644
--- 
a/inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/conf/ConfigJetty.java
+++ 
b/inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/conf/ConfigJetty.java
@@ -62,6 +62,7 @@ public class ConfigJetty implements Closeable {
     }
 
     private void initJetty() throws Exception {
+        // not using resource try to avoid AutoClosable's close() on the given 
stream
         ServerConnector connector = new ServerConnector(this.server);
         connector.setPort(conf.getInt(
                 AgentConstants.AGENT_HTTP_PORT, 
AgentConstants.DEFAULT_AGENT_HTTP_PORT));
diff --git 
a/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/util/AESUtils.java
 
b/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/util/AESUtils.java
index a3676421f..c4fd0fba9 100644
--- 
a/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/util/AESUtils.java
+++ 
b/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/util/AESUtils.java
@@ -58,8 +58,9 @@ public class AESUtils {
     private static Properties getApplicationProperties() throws IOException {
         Properties properties = new Properties();
         String path = 
Thread.currentThread().getContextClassLoader().getResource("").getPath() + 
CONFIG_FILE;
-        InputStream inputStream = new 
BufferedInputStream(Files.newInputStream(Paths.get(path)));
-        properties.load(inputStream);
+        try (InputStream inputStream = new 
BufferedInputStream(Files.newInputStream(Paths.get(path)))) {
+            properties.load(inputStream);
+        }
         return properties;
     }
 
@@ -189,4 +190,4 @@ public class AESUtils {
         }
         return result;
     }
-}
\ No newline at end of file
+}

Reply via email to