From 5fd55c6e90731995a7d8c19f63d30ee8a6abb415 Mon Sep 17 00:00:00 2001 From: AvinashS Date: Wed, 20 Sep 2017 18:35:25 +0530 Subject: Fix run time and static error findings Change-Id: I9caee424003a522f25227c098588e9b77b4b6bdb IssueId: VNFSDK-94 Signed-off-by: AvinashS --- .../src/main/java/org/onap/validation/csar/CsarUtil.java | 11 +++-------- .../src/main/java/org/onap/validation/csar/FileUtil.java | 3 +-- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/csarvalidation/src/main/java/org/onap/validation/csar/CsarUtil.java b/csarvalidation/src/main/java/org/onap/validation/csar/CsarUtil.java index ee0110c..4367f0d 100644 --- a/csarvalidation/src/main/java/org/onap/validation/csar/CsarUtil.java +++ b/csarvalidation/src/main/java/org/onap/validation/csar/CsarUtil.java @@ -41,8 +41,6 @@ import java.util.zip.ZipFile; public class CsarUtil { private static final Logger logger = LoggerFactory.getLogger(CsarUtil.class); - - public static String getUnzipDir(String dirName) { File tmpDir = new File(File.separator + dirName); @@ -61,11 +59,10 @@ public class CsarUtil { * e1 */ public static HashMap unzip(String zipFileName, String extPlace) throws IOException { - ZipFile zipFile = null; - HashMap unzipFileNames = new HashMap(); + HashMap unzipFileNames = new HashMap<>(); + + try(ZipFile zipFile = new ZipFile(zipFileName)) { - try { - zipFile = new ZipFile(zipFileName); Enumeration fileEn = zipFile.entries(); byte[] buffer = new byte[CommonConstants.BUFFER_SIZE]; @@ -98,8 +95,6 @@ public class CsarUtil { closeInputStream(input); } } - } finally { - FileUtil.closeZipFile(zipFile); } return unzipFileNames; } diff --git a/csarvalidation/src/main/java/org/onap/validation/csar/FileUtil.java b/csarvalidation/src/main/java/org/onap/validation/csar/FileUtil.java index 82f6ff4..d3cfd0a 100644 --- a/csarvalidation/src/main/java/org/onap/validation/csar/FileUtil.java +++ b/csarvalidation/src/main/java/org/onap/validation/csar/FileUtil.java @@ -141,8 +141,7 @@ public final class FileUtil { try { if (zipFile != null) { zipFile.close(); - zipFile = null; - } + } } catch (IOException e1) { logger.info("close ZipFile error!"); } -- cgit 1.2.3-korg