Skip to content

Commit

Permalink
[FLINK-33981][runtime] Fix not closing DirectoryStream after listing …
Browse files Browse the repository at this point in the history
…local state files
  • Loading branch information
fengjiajie authored and 1996fanrui committed Feb 5, 2024
1 parent de2d175 commit 360c1a0
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
* This class holds the all {@link TaskLocalStateStoreImpl} objects for a task executor (manager).
Expand Down Expand Up @@ -293,9 +294,11 @@ private Collection<AllocationID> findStoredAllocations() {
@Nonnull
static Collection<Path> listAllocationDirectoriesIn(File localStateRootDirectory)
throws IOException {
return Files.list(localStateRootDirectory.toPath())
.filter(path -> path.getFileName().toString().startsWith(ALLOCATION_DIR_PREFIX))
.collect(Collectors.toList());
try (Stream<Path> fileListStream = Files.list(localStateRootDirectory.toPath())) {
return fileListStream
.filter(path -> path.getFileName().toString().startsWith(ALLOCATION_DIR_PREFIX))
.collect(Collectors.toList());
}
}

public void shutdown() {
Expand Down

0 comments on commit 360c1a0

Please sign in to comment.