Plug a `JarFile` resource leak
This commit is contained in:
parent
e63de76139
commit
eaf1c0af85
|
@ -392,11 +392,10 @@ public class AnalysisScope {
|
|||
}
|
||||
|
||||
public String getJavaLibraryVersion() throws IllegalStateException {
|
||||
JarFile rtJar = getRtJar();
|
||||
if (rtJar == null) {
|
||||
throw new IllegalStateException("cannot find runtime libraries");
|
||||
}
|
||||
try {
|
||||
try (final JarFile rtJar = getRtJar()) {
|
||||
if (rtJar == null) {
|
||||
throw new IllegalStateException("cannot find runtime libraries");
|
||||
}
|
||||
Manifest man = rtJar.getManifest();
|
||||
assert man != null : "runtime library has no manifest!";
|
||||
String result = man.getMainAttributes().getValue("Specification-Version");
|
||||
|
|
Loading…
Reference in New Issue