From a18c1354055e54c5d9d9b7bdc7cf8542175e7622 Mon Sep 17 00:00:00 2001 From: Manamohan Satapathy Date: Mon, 17 Dec 2018 10:33:58 +0530 Subject: Use try-with-resources : Sonar:Blocker BpmnInstaller.java:L163 Change-Id: I20d81f7ef77446e50a4034d755537d1ca0b2d92b Issue-ID: SO-1333 Signed-off-by: Manamohan Satapathy --- .../java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'asdc-controller') diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java index e4a4c7cdfb..486844ae02 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java @@ -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); + } } } -- cgit 1.2.3-korg