[ 
https://issues.apache.org/jira/browse/FLINK-10690?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16666932#comment-16666932
 ] 

ASF GitHub Bot commented on FLINK-10690:
----------------------------------------

dawidwys commented on a change in pull request #6939: [FLINK-10690][tests] Fix 
Files.list resource leaks
URL: https://github.com/apache/flink/pull/6939#discussion_r228853459
 
 

 ##########
 File path: 
flink-tests/src/test/java/org/apache/flink/test/checkpointing/ResumeCheckpointManuallyITCase.java
 ##########
 @@ -326,16 +327,20 @@ private static void 
waitUntilExternalizedCheckpointCreated(File checkpointDir, J
        }
 
        private static Optional<Path> findExternalizedCheckpoint(File 
checkpointDir, JobID jobId) throws IOException {
-               return 
Files.list(checkpointDir.toPath().resolve(jobId.toString()))
-                       .filter(path -> 
path.getFileName().toString().startsWith("chk-"))
-                       .filter(path -> {
-                               try {
-                                       return Files.list(path).anyMatch(child 
-> child.getFileName().toString().contains("meta"));
-                               } catch (IOException ignored) {
-                                       return false;
-                               }
-                       })
-                       .findAny();
+               try (Stream<Path> checkpoints = 
Files.list(checkpointDir.toPath().resolve(jobId.toString()))) {
+                       return checkpoints
+                               .filter(path -> 
path.getFileName().toString().startsWith("chk-"))
+                               .filter(path -> {
+                                       try {
+                                               try (Stream<Path> 
checkpointFiles = Files.list(path)) {
 
 Review comment:
   Why not merge those two `tries`?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Tests leak resources via Files.list
> -----------------------------------
>
>                 Key: FLINK-10690
>                 URL: https://issues.apache.org/jira/browse/FLINK-10690
>             Project: Flink
>          Issue Type: Bug
>          Components: Tests
>    Affects Versions: 1.5.4, 1.6.1, 1.7.0
>            Reporter: Chesnay Schepler
>            Assignee: Chesnay Schepler
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.5.6, 1.6.3, 1.7.0
>
>
> {{Files.list}} has the unfortunate property that is has to be explicitly 
> closed to cleanup the underlying {{DirectoryStream}}. This is _not_ done 
> automatically by collectors.
> Several tests don't close the stream.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to