summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorajay priyadarshi <ajay.priyadarshi@ril.com>2018-02-19 17:16:30 +0530
committerajay priyadarshi <ajay.priyadarshi@ril.com>2018-02-19 17:16:30 +0530
commit6976625e7fa87f70e099328944c330703c36c274 (patch)
tree732084f93ae13a5be0b85266117d46c884f2708f
parentaf25e34f178aac1e487f1462fa2ea4e635b11427 (diff)
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 <ajay.priyadarshi@ril.com>
-rw-r--r--ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/utils/Gunzip.java22
1 files 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
+}