You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/04/09 03:38:58 UTC

[GitHub] [incubator-inlong] healchow commented on a diff in pull request #3588: [INLONG-3587][Agent] Auto close file resource after list

healchow commented on code in PR #3588:
URL: https://github.com/apache/incubator-inlong/pull/3588#discussion_r846569042


##########
inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/trigger/DirectoryTrigger.java:
##########
@@ -159,9 +159,11 @@ private void registerNewDir(PathPattern entity,
                 LOGGER.info("overflow got {}", parentPath);
                 // check whether parent path is valid.
                 if (Files.isDirectory(parentPath)) {
-                    for (Iterator<Path> it = Files.list(parentPath).iterator(); it.hasNext();) {
-                        Path childPath = it.next();
-                        registerAllSubDir(entity, parentPath.resolve(childPath), tmpWatchers);
+                    try(final Stream<Path> pathStream = Files.list(parentPath)) {

Review Comment:
   Please refer to the link <https://github.com/apache/incubator-inlong/discussions/3082> to set your code style, then pull the request again.



-- 
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