diff --git a/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasher.java b/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasher.java index fada88cc149..453482facc4 100644 --- a/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasher.java +++ b/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasher.java @@ -38,14 +38,15 @@ public class TestGCBasher { HashMap deps = new HashMap<>(); FileSystem fs = FileSystems.getFileSystem(URI.create("jrt:/")); - Stream s = Files.walk(fs.getPath("/")); - for (Path p : (Iterable)s::iterator) { - if (p.toString().endsWith(".class") && - !p.getFileName().toString().equals("module-info.class")) { - byte[] data = Files.readAllBytes(p); - Decompiler d = new Decompiler(data); - ClassInfo ci = d.getClassInfo(); - deps.put(ci.getName(), ci); + try (Stream s = Files.walk(fs.getPath("/"))) { + for (Path p : (Iterable)s::iterator) { + if (p.toString().endsWith(".class") && + !p.getFileName().toString().equals("module-info.class")) { + byte[] data = Files.readAllBytes(p); + Decompiler d = new Decompiler(data); + ClassInfo ci = d.getClassInfo(); + deps.put(ci.getName(), ci); + } } } }