aboutsummaryrefslogtreecommitdiffstats
path: root/common-app-api/src/main/java/org/openecomp
diff options
context:
space:
mode:
authorya107f <ya107f@intl.att.com>2018-01-08 14:04:44 +0200
committerVitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com>2018-01-10 15:04:28 +0000
commit46562cc3c56e45d3e574ff20a88a6d25391abdc2 (patch)
tree31d23b079e4d443df25ffa511016818072ef6acd /common-app-api/src/main/java/org/openecomp
parent38cf5fed407ed0aa5e7adb72c90b82bccccfe3e0 (diff)
ZipOutputStream Cleanup
Enclose ZipOutputStream handling with try with resources block for proper stream cleanup. Change-Id: I2565ef411519f127208a4f966001edf735cb68c0 Signed-off-by: ya107f <ya107f@intl.att.com> Issue-ID: SDC-886 Signed-off-by: vempo <vitaliy.emporopulo@amdocs.com>
Diffstat (limited to 'common-app-api/src/main/java/org/openecomp')
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/util/ZipUtil.java15
1 files changed, 8 insertions, 7 deletions
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();
}