From 46562cc3c56e45d3e574ff20a88a6d25391abdc2 Mon Sep 17 00:00:00 2001 From: ya107f Date: Mon, 8 Jan 2018 14:04:44 +0200 Subject: ZipOutputStream Cleanup Enclose ZipOutputStream handling with try with resources block for proper stream cleanup. Change-Id: I2565ef411519f127208a4f966001edf735cb68c0 Signed-off-by: ya107f Issue-ID: SDC-886 Signed-off-by: vempo --- .../main/java/org/openecomp/sdc/common/util/ZipUtil.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'common-app-api/src') diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/ZipUtil.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ZipUtil.java index 386a66bafe..c9207b2f42 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/ZipUtil.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ZipUtil.java @@ -128,13 +128,14 @@ public class ZipUtil { public static byte[] zipBytes(byte[] input) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ZipOutputStream zos = new ZipOutputStream(baos); - ZipEntry entry = new ZipEntry("zip"); - entry.setSize(input.length); - zos.putNextEntry(entry); - zos.write(input); - zos.closeEntry(); - zos.close(); + try (ZipOutputStream zos = new ZipOutputStream(baos)) { + ZipEntry entry = new ZipEntry("zip"); + entry.setSize(input.length); + zos.putNextEntry(entry); + zos.write(input); + zos.closeEntry(); + zos.close(); + } return baos.toByteArray(); } -- cgit 1.2.3-korg