diff --git a/src/java.base/share/classes/java/util/jar/JarFile.java b/src/java.base/share/classes/java/util/jar/JarFile.java index 43c56a86bb0..17f599d47c3 100644 --- a/src/java.base/share/classes/java/util/jar/JarFile.java +++ b/src/java.base/share/classes/java/util/jar/JarFile.java @@ -423,7 +423,9 @@ public class JarFile extends ZipFile { } man = new Manifest(jv, new ByteArrayInputStream(b), getName()); } else { - man = new Manifest(super.getInputStream(manEntry), getName()); + try (InputStream is = super.getInputStream(manEntry)) { + man = new Manifest(is, getName()); + } } manRef = new SoftReference<>(man); }