diff options
author | luxin <luxin7@huawei.com> | 2017-09-26 14:50:56 +0800 |
---|---|---|
committer | luxin <luxin7@huawei.com> | 2017-09-26 14:50:56 +0800 |
commit | 5348b8226d6cfedc48fa19df2c18e3eefd570ac3 (patch) | |
tree | cd0191392655cec3542eb65ddf109afa9b400ce5 | |
parent | 047eb4522ea7ae93931ef222c1ba1fa4b179a9e9 (diff) |
Close this Zipfile in vfc-svnfm
Change-Id: Idc6826b643dc217339b6c453d249e60e919b69d5
Issue-Id:VFC-391
Signed-off-by: luxin <luxin7@huawei.com>
-rw-r--r-- | huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/DownloadCsarManager.java | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/DownloadCsarManager.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/DownloadCsarManager.java index 1547f804..110d170b 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/DownloadCsarManager.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/DownloadCsarManager.java @@ -20,6 +20,7 @@ import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; +import java.io.IOException; import java.io.InputStream; import java.util.Enumeration; import java.util.zip.ZipEntry; @@ -163,13 +164,14 @@ public class DownloadCsarManager { * * @param fileName filePath * @return + * @throws IOException */ public static int unzipCSAR(String fileName, String filePath) { final int BUFFER = 2048; int status = 0; - + ZipFile zipFile = null; try { - ZipFile zipFile = new ZipFile(fileName); + zipFile = new ZipFile(fileName); Enumeration emu = zipFile.entries(); while(emu.hasMoreElements()) { ZipEntry entry = (ZipEntry)emu.nextElement(); @@ -198,11 +200,20 @@ public class DownloadCsarManager { bos.close(); bis.close(); } + status = Constant.UNZIP_SUCCESS; - zipFile.close(); + } catch(Exception e) { status = Constant.UNZIP_FAIL; - e.printStackTrace(); + LOG.error("Exception: " + e); + } finally { + if(zipFile != null) { + try { + zipFile.close(); + } catch(IOException e) { + LOG.error("IOException: " + e); + } + } } return status; } |