[bug-66584] ensure ZipPackage closes input stream when exceptions happen

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1909467 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2023-04-28 09:13:08 +00:00
parent b88f3ac0ab
commit fe3b4645b7

View File

@ -127,11 +127,9 @@ public final class ZipPackage extends OPCPackage {
*/
ZipPackage(InputStream in, PackageAccess access) throws IOException {
super(access);
ZipArchiveThresholdInputStream zis = ZipHelper.openZipStream(in); // NOSONAR
try {
try (ZipArchiveThresholdInputStream zis = ZipHelper.openZipStream(in)) {
this.zipArchive = new ZipInputStreamZipEntrySource(zis);
} catch (final IOException | RuntimeException e) {
IOUtils.closeQuietly(zis);
throw e;
}
}