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]
With regards,
Apache Git Services