diff options
-rw-r--r-- | csarvalidation/src/main/java/org/onap/validation/csar/CsarUtil.java | 11 | ||||
-rw-r--r-- | csarvalidation/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<String, String> unzip(String zipFileName, String extPlace) throws IOException { - ZipFile zipFile = null; - HashMap<String, String> unzipFileNames = new HashMap<String, String>(); + HashMap<String, String> 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!"); } |