Review request: JDK-8167630 jdeps --generate-module-info forgets to close the resource after checking any unnamed package
Mandy Chung
mandy.chung at oracle.com
Wed Oct 12 22:52:56 UTC 2016
Simple patch close the ClassFileReader with try-with-resource.
diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java
@@ -680,9 +680,9 @@
private boolean genModuleInfo(JdepsConfiguration config) throws IOException {
// check if any JAR file contains unnamed package
for (String arg : inputArgs) {
+ try (ClassFileReader reader = ClassFileReader.newInstance(Paths.get(arg))) {
Optional<String> classInUnnamedPackage =
- ClassFileReader.newInstance(Paths.get(arg))
- .entries().stream()
+ reader.entries().stream()
.filter(n -> n.endsWith(".class"))
.filter(cn -> toPackageName(cn).isEmpty())
.findFirst();
@@ -696,6 +696,7 @@
return false;
}
}
+ }
ModuleInfoBuilder builder
= new ModuleInfoBuilder(config, inputArgs, options.genModuleInfo);
Thanks
Mandy
More information about the core-libs-dev
mailing list