diff options
author | ajay priyadarshi <ajay.priyadarshi@ril.com> | 2018-03-12 17:34:33 +0530 |
---|---|---|
committer | ajay priyadarshi <ajay.priyadarshi@ril.com> | 2018-03-12 17:34:33 +0530 |
commit | 2d6cfd3c48c1c2132877df8c1fc88e0d33791260 (patch) | |
tree | 92bc0663da6b2149fa07bf154576bdec495ab528 /juju | |
parent | cc517a0c7c56543426888a5d1f0620b9587e2642 (diff) |
sonar fix: Resource handling in YamlUtil
try-with resource & logging issues fixed
file name: YamlUtil.java
Change-Id: Ib3ad9afad0b11ce3ba8bf3805c55a4247f86cc0e
Issue-ID: VFC-803
Signed-off-by: ajay priyadarshi <ajay.priyadarshi@ril.com>
Diffstat (limited to 'juju')
-rw-r--r-- | juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/common/YamlUtil.java | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/common/YamlUtil.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/common/YamlUtil.java index a1071f1..a32aad5 100644 --- a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/common/YamlUtil.java +++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/common/YamlUtil.java @@ -116,10 +116,12 @@ public class YamlUtil { name.put("default","hello,it's me"); // new Yaml().dump(config, new FileWriter("C:\\Users\\z00292420\\Desktop\\juju\\config2.yaml")); String newYaml = new Yaml().dumpAsMap(config); - Writer w = new FileWriter(new File("C:\\Users\\z00292420\\Desktop\\juju")); + try(Writer w = new FileWriter(new File("C:\\Users\\z00292420\\Desktop\\juju"))){ w.write(newYaml); - w.flush(); - w.close(); - System.out.println(newYaml); + }catch(Exception e){ + log.error("Write Yaml Error: ",e); + throw new IOException("Write Yaml Error" + e); + } + //System.out.println(newYaml); } } |