Skip to content

Commit 800b0a2

Browse files
committed
[ci] License checks leave directory streams open on traversal failure
1 parent 61c8956 commit 800b0a2

2 files changed

Lines changed: 14 additions & 12 deletions

File tree

‎tools/ci/paimon-ci-tools/src/main/java/org/apache/paimon/tools/ci/licensecheck/JarFileChecker.java‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ public static int checkPath(Path path) throws Exception {
5454
}
5555

5656
private static List<Path> getBuildJars(Path path) throws IOException {
57-
return Files.walk(path)
58-
.filter(file -> file.toString().endsWith(".jar"))
59-
.collect(Collectors.toList());
57+
try (Stream<Path> files = Files.walk(path)) {
58+
return files.filter(file -> file.toString().endsWith(".jar"))
59+
.collect(Collectors.toList());
60+
}
6061
}
6162

6263
static int checkJar(Path file) throws Exception {

‎tools/ci/paimon-ci-tools/src/main/java/org/apache/paimon/tools/ci/licensecheck/NoticeFileChecker.java‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -351,15 +351,16 @@ private static String convertProblemsToIndentedString(List<String> problems, Str
351351
}
352352

353353
private static List<Path> findNoticeFiles(Path root) throws IOException {
354-
return Files.walk(root)
355-
.filter(
356-
file -> {
357-
int nameCount = file.getNameCount();
358-
return file.getName(nameCount - 3).toString().equals("resources")
359-
&& file.getName(nameCount - 2).toString().equals("META-INF")
360-
&& file.getName(nameCount - 1).toString().equals("NOTICE");
361-
})
362-
.collect(Collectors.toList());
354+
try (Stream<Path> files = Files.walk(root)) {
355+
return files.filter(
356+
file -> {
357+
int nameCount = file.getNameCount();
358+
return file.getName(nameCount - 3).toString().equals("resources")
359+
&& file.getName(nameCount - 2).toString().equals("META-INF")
360+
&& file.getName(nameCount - 1).toString().equals("NOTICE");
361+
})
362+
.collect(Collectors.toList());
363+
}
363364
}
364365

365366
private static List<String> loadFromResources(String fileName) {

0 commit comments

Comments
 (0)