Changed try to try with resource 77/15077/1
authorshashikanth <shashikanth.vh@huawei.com>
Mon, 25 Sep 2017 13:11:45 +0000 (18:41 +0530)
committershashikanth <shashikanth.vh@huawei.com>
Mon, 25 Sep 2017 13:11:46 +0000 (18:41 +0530)
Change this condition so that it does not always evaluate to "false"
https://sonar.onap.org/component_issues?id=org.openecomp.so%3Aso#resolved=false|severities=BLOCKER

Issue-Id:SO-118
Change-Id: I0ebc001b3e7f6a13a2d309b69cc4133271a9e87e
Signed-off-by: shashikanth.vh <shashikanth.vh@huawei.com>
bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadConfigTask.java

index 6249040..b27a2fa 100644 (file)
@@ -67,29 +67,12 @@ public class ReadConfigTask extends BaseTask {
                synchronized (ReadConfigTask.class) {
                        if (properties == null) {
                                properties = new Properties();
-
-                               InputStream stream = null;
-
-                               try {
-                                       stream = getClass().getResourceAsStream(thePropertiesFile);
-
-                                       if (stream == null) {
-                                               throw new IOException("Resource not found: " + thePropertiesFile);
-                                       }
+                               try (InputStream stream = getClass().getResourceAsStream(thePropertiesFile)) {
 
                                        properties.load(stream);
 
-                                       stream.close();
-                                       stream = null;
-
-                               } finally {
-                                       if (stream != null) {
-                                               try {
-                                                       stream.close();
-                                               } catch (Exception e) {
-                                                   msoLogger.debug("Exception:", e);
-                                               }
-                                       }
+                               } catch (Exception e) {
+                                       msoLogger.debug("Exception at readResourceFile stream: " + e);
                                }
                        }
                }