From: AR00500721 Date: Mon, 6 May 2019 12:53:56 +0000 (+0530) Subject: Fixing Sonar Blocker issue X-Git-Tag: 1.0.1~5^2 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=1fbde0d64a98efcb040cf38b3c1e193019b11b5c;p=dcaegen2%2Fservices%2Fmapper.git Fixing Sonar Blocker issue Fixing Sonar blocker issue on class FetchDynamicConfig.java 1.FileWriter stream closing at Line157 2.Handling Null pointer Exception at Line179 Sonar Link:https://sonar.onap.org/project/issues?fileUuids=AWkprNOu4d1SZrzfYLdQ&id=org.onap.dcaegen2.services.mapper%3Amapper&open=AWomAhrY4d1SZrzfe8ua&resolved=false&severities=BLOCKER&types=BUG Issue-ID: DCAEGEN2-1477 Change-Id: Ie016d4811a0e98dc1100079990681b6c55545991 Signed-off-by: AR00500721 --- diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/utils/FetchDynamicConfig.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/utils/FetchDynamicConfig.java index bb9b127..022a586 100644 --- a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/utils/FetchDynamicConfig.java +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/utils/FetchDynamicConfig.java @@ -158,6 +158,7 @@ public class FetchDynamicConfig { PrintWriter printWriter = new PrintWriter(fstream); printWriter.print(indentedretstring); printWriter.close(); + fstream.close(); debugLogger.info("New Config successfully written to local file to " + configFile); } catch (IOException e) { @@ -176,7 +177,7 @@ public class FetchDynamicConfig { file = ResourceUtils.getFile("classpath:" + configFileName); content = new String(Files.readAllBytes(file.toPath())); } catch (FileNotFoundException e) { - errorLogger.error("colud not find file :", file.getName()); + errorLogger.error("colud not find file :",configFileName); } catch (IOException e) { errorLogger.error("unable to read the file , reason:", e.getCause());