Fix use try-with-resources sonar issues 41/57141/3
authorParshad Patel <pars.patel@samsung.com>
Mon, 23 Jul 2018 09:47:12 +0000 (18:47 +0900)
committerParshad Patel <pars.patel@samsung.com>
Tue, 24 Jul 2018 05:25:51 +0000 (14:25 +0900)
Replace try with try-with-resources statement

Issue-ID: SO-703
Change-Id: I971b61af2070a6856c751ed36050dd018216fe03
Signed-off-by: Parshad Patel <pars.patel@samsung.com>
common/src/main/java/org/openecomp/mso/client/defaultproperties/DefaultAAIPropertiesImpl.java
common/src/main/java/org/openecomp/mso/client/defaultproperties/PolicyRestPropertiesImpl.java

index 3f5bfa9..ce08759 100644 (file)
@@ -40,8 +40,7 @@ public class DefaultAAIPropertiesImpl implements AAIProperties {
        public DefaultAAIPropertiesImpl() {
                File initialFile = new File("src/test/resources/aai.properties");
                Map<Object, Object> temp;
-               try {
-                   InputStream targetStream = new FileInputStream(initialFile);
+               try(InputStream targetStream = new FileInputStream(initialFile)) {
                        Properties properties = new Properties();
                        properties.load(targetStream);
                        temp = properties;
index 77d67d7..655dc5a 100644 (file)
@@ -38,10 +38,9 @@ public class PolicyRestPropertiesImpl implements PolicyRestProperties {
        final Map<Object, Object> props;
        public PolicyRestPropertiesImpl() {
                File initialFile = new File("src/test/resources/policy.properties");
-               InputStream targetStream;
+               
                Map<Object, Object> temp;
-               try {
-                       targetStream = new FileInputStream(initialFile);
+               try(InputStream targetStream = new FileInputStream(initialFile)) {
                        Properties properties = new Properties();
                        properties.load(targetStream);
                        temp = properties;