From 6976625e7fa87f70e099328944c330703c36c274 Mon Sep 17 00:00:00 2001 From: ajay priyadarshi Date: Mon, 19 Feb 2018 17:16:30 +0530 Subject: sonar fix: resources handling in Gunzip.java emsdriver/commons/utils/Gunzip.java file name: Gunzip.java Change-Id: I6a1e41bd2bee91bf87b06691f05f7cbc50b67973 Issue-ID: VFC-772 Signed-off-by: ajay priyadarshi --- .../vfc/nfvo/emsdriver/commons/utils/Gunzip.java | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/utils/Gunzip.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/utils/Gunzip.java index 9098c27..a24afbe 100644 --- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/utils/Gunzip.java +++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/utils/Gunzip.java @@ -24,24 +24,22 @@ public class Gunzip { * */ public void unCompress(String gzFileName, String toFile) throws IOException { - GZIPInputStream gzIn = null; - FileOutputStream fileOutput = null; - FileInputStream gzInput = new FileInputStream(gzFileName); try { - gzIn = new GZIPInputStream(gzInput); + FileInputStream gzInput = new FileInputStream(gzFileName); + GZIPInputStream gzIn = new GZIPInputStream(gzInput); File tofile = new File(toFile); enable(tofile); - fileOutput = new FileOutputStream(tofile, false); - - moveBytes(gzIn, fileOutput, -1, -1, 1024); - } finally { - if (gzIn != null) { + FileOutputStream fileOutput = new FileOutputStream(tofile, false); + try{ + moveBytes(gzIn, fileOutput, -1, -1, 1024); + } finally { + gzInput.close(); gzIn.close(); - } - if (fileOutput != null) { fileOutput.close(); } + }catch(IOException e){ + throw e; } } @@ -81,4 +79,4 @@ public class Gunzip { return totalNum; } -} \ No newline at end of file +} -- cgit 1.2.3-korg