summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authork.kazak <k.kazak@samsung.com>2019-08-14 10:18:31 +0200
committerLukasz Muszkieta <lukasz.muszkieta@nokia.com>2019-08-19 10:52:19 +0000
commit81f26b4c1837c9f8ff49619782fe01d99f4f0683 (patch)
treed845ed5c21e2c55545320bd39b7157a27e60e241 /common
parent5b17afb416e3ab2d3f58694d275e67f20af5a1c6 (diff)
Close input streams via try-with-resources
DefaultDmaapPropertiesImpl: close FileInputStream after loading ServicePluginFactory: close HttpClient if processing fails close application.properties InputStream after loading remove redundant catch block if behavior is the same add logging of exception in finally block BpmnInstaller: close csarFile if processing fails Change-Id: Ic6f942c401277c5150c5cc1297aba27ccd40694c Coverity-scan: CID-203903, CID-211476, CID-211615, CID-219308 Issue-ID: SO-2211 Signed-off-by: k.kazak <k.kazak@samsung.com>
Diffstat (limited to 'common')
-rw-r--r--common/src/main/java/org/onap/so/client/defaultproperties/DefaultDmaapPropertiesImpl.java9
1 files changed, 5 insertions, 4 deletions
diff --git a/common/src/main/java/org/onap/so/client/defaultproperties/DefaultDmaapPropertiesImpl.java b/common/src/main/java/org/onap/so/client/defaultproperties/DefaultDmaapPropertiesImpl.java
index 4ca5690188..8ef08057e6 100644
--- a/common/src/main/java/org/onap/so/client/defaultproperties/DefaultDmaapPropertiesImpl.java
+++ b/common/src/main/java/org/onap/so/client/defaultproperties/DefaultDmaapPropertiesImpl.java
@@ -35,11 +35,12 @@ public class DefaultDmaapPropertiesImpl implements DmaapProperties {
public DefaultDmaapPropertiesImpl() throws IOException {
File initialFile = new File("src/test/resources/dmaap.properties");
- InputStream targetStream = new FileInputStream(initialFile);
Properties properties = new Properties();
- properties.load(targetStream);
- this.properties = new HashMap<>();
- properties.forEach((key, value) -> this.properties.put((String) key, (String) value));
+ try (InputStream targetStream = new FileInputStream(initialFile)) {
+ properties.load(targetStream);
+ this.properties = new HashMap<>();
+ properties.forEach((key, value) -> this.properties.put((String) key, (String) value));
+ }
}
@Override