aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCoreBPMN/src/main/java
diff options
context:
space:
mode:
authorshashikanth <shashikanth.vh@huawei.com>2017-09-25 15:30:17 +0530
committerShashikanth VH <shashikanth.vh@huawei.com>2017-09-25 10:06:10 +0000
commit57486a2a5965511a0740eee3e2ec19610d7bfe45 (patch)
tree127a9f19453eb46b53d1183a99beb766aea1593f /bpmn/MSOCoreBPMN/src/main/java
parent6ae289e48a8d286e357544d4a8dd4b377a8e6993 (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: I8885beed7ab1fa2e26e1155665d9507746bd9906 Signed-off-by: shashikanth.vh <shashikanth.vh@huawei.com>
Diffstat (limited to 'bpmn/MSOCoreBPMN/src/main/java')
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java23
1 files changed, 5 insertions, 18 deletions
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java
index 1cf434052c..c2b832812e 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java
@@ -312,15 +312,10 @@ public final class XmlTool {
* @throws IOException if there is a problem reading the file
*/
private static String readResourceFile(String file) throws IOException {
- InputStream stream = null;
- try {
- stream = XmlTool.class.getClassLoader().getResourceAsStream(file);
- if (stream == null) {
- throw new FileNotFoundException("No such resource file: " + file);
- }
+ try (InputStream stream = XmlTool.class.getClassLoader().getResourceAsStream(file);
+ Reader reader = new InputStreamReader(stream, "UTF-8")) {
- Reader reader = new InputStreamReader(stream, "UTF-8");
StringBuilder out = new StringBuilder();
char[] buf = new char[1024];
int n;
@@ -328,18 +323,10 @@ public final class XmlTool {
while ((n = reader.read(buf)) >= 0) {
out.append(buf, 0, n);
}
-
- stream.close();
- stream = null;
return out.toString();
- } finally {
- if (stream != null) {
- try {
- stream.close();
- } catch (Exception e) {
- LOGGER.debug("Exception at readResourceFile close stream: " + e);
- }
- }
+ } catch (Exception e) {
+ LOGGER.debug("Exception at readResourceFile stream: " + e);
+ return null;
}
}