summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-widget-ms
diff options
context:
space:
mode:
authorParshad Patel <pars.patel@samsung.com>2018-07-26 17:26:56 +0900
committerParshad Patel <pars.patel@samsung.com>2018-08-03 16:01:19 +0900
commit2f3daf7701f9d0a6a4388c9391eeeb91bbdfb3b6 (patch)
tree226f075fd3c9d1ae50707660d67dbfbccd0cd73f /ecomp-portal-widget-ms
parentfe3a67c11b65d7989a6ef648c3f34eee8abe7394 (diff)
Fix sonar issues
Fix use try-with-resource issue in portal Issue-ID: PORTAL-342 Change-Id: Ieda3384feddae688c66890743978eaf4deda41e0 Signed-off-by: Parshad Patel <pars.patel@samsung.com>
Diffstat (limited to 'ecomp-portal-widget-ms')
-rw-r--r--ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/InitializationServiceImpl.java9
1 files changed, 2 insertions, 7 deletions
diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/InitializationServiceImpl.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/InitializationServiceImpl.java
index cbc0c9d0..c9365c46 100644
--- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/InitializationServiceImpl.java
+++ b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/InitializationServiceImpl.java
@@ -114,18 +114,13 @@ public class InitializationServiceImpl implements InitializationService {
long widgetId = widgetCatalogService.saveWidgetCatalog(newWidget);
File tmpZipFile = new File("/tmp/" + fileLocation);
- InputStream fileInputStream = null;
- OutputStream outputStream = null;
- try {
- fileInputStream = this.getClass().getClassLoader().getResourceAsStream(fileLocation);
- outputStream = new FileOutputStream(tmpZipFile);
+ try(OutputStream outputStream = new FileOutputStream(tmpZipFile);
+ InputStream fileInputStream = this.getClass().getClassLoader().getResourceAsStream(fileLocation)) {
int read = 0;
byte[] bytes = new byte[4096];
while ((read = fileInputStream.read(bytes)) != -1) {
outputStream.write(bytes, 0, read);
}
- outputStream.close();
- fileInputStream.close();
} catch (Exception e) {
logger.error(
"Exception occurred while performing InitializationServiceImpl.initCommonWidget in widget microservices. Details:", e);