From 671dfba802bbae9a10182278ee8a1340dcd46472 Mon Sep 17 00:00:00 2001 From: Jaikiran Pai Date: Wed, 16 Sep 2020 15:13:32 +0000 Subject: [PATCH] 6714834: JarFile.getManifest() leaves an open InputStream as an undocumented side effect Reviewed-by: lancea, alanb --- src/java.base/share/classes/java/util/jar/JarFile.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); }