Skip to content

Commit 98e067b

Browse files
authored
Fix unclosed directory stream in ClassReaders (elastic#92890)
Using Files.walk requires closing the returned stream. This commit fixes a helper method in ClassReaders to use try-with-resources with the returned stream. closes elastic#92866
1 parent 3c54c7a commit 98e067b

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

docs/changelog/92890.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 92890
2+
summary: Fix unclosed directory stream in `ClassReaders`
3+
area: Infra/Plugins
4+
type: bug
5+
issues:
6+
- 92866

libs/plugin-scanner/src/main/java/org/elasticsearch/plugin/scanner/ClassReaders.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,8 @@ private static List<ClassReader> classesInJar(Path jar) {
8888
}
8989

9090
private static List<ClassReader> classesInPath(Path root) {
91-
try {
92-
return Files.walk(root)
93-
.filter(p -> p.toString().endsWith(".class"))
91+
try (var stream = Files.walk(root)) {
92+
return stream.filter(p -> p.toString().endsWith(".class"))
9493
.filter(p -> p.toString().endsWith(MODULE_INFO) == false)
9594
.filter(p -> p.toString().startsWith("/META-INF") == false)// skip multi-release files
9695
.map(p -> {

0 commit comments

Comments
 (0)