Use try-with-resources 93/74693/1
authorManamohan Satapathy <MS00534989@techmahindra.com>
Mon, 17 Dec 2018 05:03:58 +0000 (10:33 +0530)
committerManamohan Satapathy <MS00534989@techmahindra.com>
Mon, 17 Dec 2018 05:07:55 +0000 (10:37 +0530)
:
Sonar:Blocker

BpmnInstaller.java:L163

Change-Id: I20d81f7ef77446e50a4034d755537d1ca0b2d92b
Issue-ID: SO-1333
Signed-off-by: Manamohan Satapathy <MS00534989@techmahindra.com>
asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java

index e4a4c7c..486844a 100644 (file)
@@ -158,14 +158,19 @@ public class BpmnInstaller {
                 return requestEntity;
        }
        
-       protected void extractBpmnFileFromCsar(ZipInputStream zipIn, String fileName) throws IOException {
+       /* protected void extractBpmnFileFromCsar(ZipInputStream zipIn, String fileName) throws IOException */
+        protected void extractBpmnFileFromCsar(ZipInputStream zipIn, String fileName)  {
                String filePath = Paths.get(System.getProperty("mso.config.path"), "ASDC", fileName).normalize().toString();
-               BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(filePath));
+               /* BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(filePath)); */
+               try (BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(filePath))){
                byte[] bytesIn = new byte[4096];
                int read = 0;
                while ((read = zipIn.read(bytesIn)) != -1) {
                        outputStream.write(bytesIn, 0, read);
                }
-               outputStream.close();
+               /* outputStream.close(); */
+               } catch (IOException e) {
+              LOGGER.error("Unable to open file.", e);
+        }
        }
 }