summaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCoreBPMN
diff options
context:
space:
mode:
authorSeshu Kumar M <seshu.kumar.m@huawei.com>2017-09-25 16:46:40 +0000
committerGerrit Code Review <gerrit@onap.org>2017-09-25 16:46:40 +0000
commit7e1b355a6920167c3d786072adce6c69dc3c1101 (patch)
treee717e29d85eb4a9bef5f5ad05ed96593d2371944 /bpmn/MSOCoreBPMN
parent868c509c490d0b6fcdd5273320fb173e11520f8f (diff)
parent55322d92170dce6eb095dc7cc15c77c1deca01ac (diff)
Merge "Changed try to try with resource"
Diffstat (limited to 'bpmn/MSOCoreBPMN')
-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);