You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by "vernedeng (via GitHub)" <gi...@apache.org> on 2023/03/08 02:15:18 UTC

[GitHub] [inlong] vernedeng commented on a diff in pull request #7549: [INLONG-7548][Agent][Manager] Use try-with-resource to close resources

vernedeng commented on code in PR #7549:
URL: https://github.com/apache/inlong/pull/7549#discussion_r1128878288


##########
inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/conf/ConfigJetty.java:
##########
@@ -62,10 +62,11 @@ public ConfigJetty(JobManager jobManager, TriggerManager triggerManager) {
     }
 
     private void initJetty() throws Exception {
-        ServerConnector connector = new ServerConnector(this.server);
-        connector.setPort(conf.getInt(
-                AgentConstants.AGENT_HTTP_PORT, AgentConstants.DEFAULT_AGENT_HTTP_PORT));
-        server.setConnectors(new Connector[]{connector});
+        try (ServerConnector connector = new ServerConnector(this.server)) {
+            connector.setPort(conf.getInt(
+                    AgentConstants.AGENT_HTTP_PORT, AgentConstants.DEFAULT_AGENT_HTTP_PORT));
+            server.setConnectors(new Connector[]{connector});
+        }

Review Comment:
   It seems that the server needs to hold this connector rather than close it immediately.
   The connector will be closed when call server.stop().



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org