fix resource leak due to Files.walk

This commit is contained in:
lujie
2021-10-19 11:33:27 +08:00
parent adaf031311
commit 3b791b49c7

View File

@@ -284,8 +284,8 @@ public class DeadLinksChecker {
private List<Path> listMdFiles(Path pagesDirectory) {
try {
return Files.walk(pagesDirectory)
try (Stream<Path> stream = Files.walk(pagesDirectory)) {
return stream
.filter(Files::isRegularFile)
.filter(path -> path.toString().endsWith(".md"))
.collect(Collectors.toList());