From 1fbde0d64a98efcb040cf38b3c1e193019b11b5c Mon Sep 17 00:00:00 2001 From: AR00500721 Date: Mon, 6 May 2019 18:23:56 +0530 Subject: [PATCH] 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 --- .../java/org/onap/universalvesadapter/utils/FetchDynamicConfig.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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()); -- 2.16.6