summaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCoreBPMN/src
diff options
context:
space:
mode:
authorshashikanth <shashikanth.vh@huawei.com>2017-09-25 18:36:47 +0530
committershashikanth <shashikanth.vh@huawei.com>2017-09-25 18:36:48 +0530
commit55322d92170dce6eb095dc7cc15c77c1deca01ac (patch)
tree88b0a79ee69184a335bd3c7c797789d7dbff1b09 /bpmn/MSOCoreBPMN/src
parentcf8b91603edf8eaad3cb84c85a222c2e9793bf33 (diff)
Changed try to try with resource
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: I29713fa4c4623439addb4b7f30325dcb7e1ccfcc Signed-off-by: shashikanth.vh <shashikanth.vh@huawei.com>
Diffstat (limited to 'bpmn/MSOCoreBPMN/src')
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadFileTask.java26
1 files changed, 4 insertions, 22 deletions
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadFileTask.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadFileTask.java
index 6b3cb5a1db..af38053fac 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadFileTask.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadFileTask.java
@@ -76,36 +76,18 @@ public class ReadFileTask extends BaseTask {
Object value = execution.getVariable(theInputVariable);
if (value == null) {
- InputStream xmlStream = null;
-
- try {
- xmlStream = getClass().getResourceAsStream(theFile);
-
- if (xmlStream == null) {
- throw new IOException("Resource not found: " + theFile);
- }
-
- BufferedReader reader = new BufferedReader(new InputStreamReader(xmlStream));
+ try (InputStream xmlStream = getClass().getResourceAsStream(theFile);
+ BufferedReader reader = new BufferedReader(new InputStreamReader(xmlStream))) {
StringBuilder output = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
output.append(line);
}
-
- xmlStream.close();
- xmlStream = null;
-
value = output.toString();
- } finally {
- if (xmlStream != null) {
- try {
- xmlStream.close();
- } catch (Exception e) {
- msoLogger.debug("Exception ", e);
- }
- }
+ } catch (Exception e) {
+ msoLogger.debug("Exception at readResourceFile stream: " + e);
}
}
execution.setVariable(theInputVariable, value);