Fixing Sonar Blocker issue 31/87031/1
authorAR00500721 <AR00500721@techmahindra.com>
Mon, 6 May 2019 12:53:56 +0000 (18:23 +0530)
committerAR00500721 <AR00500721@techmahindra.com>
Mon, 6 May 2019 12:53:56 +0000 (18:23 +0530)
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 <AR00500721@techmahindra.com>
UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/utils/FetchDynamicConfig.java

index bb9b127..022a586 100644 (file)
@@ -158,6 +158,7 @@ public class FetchDynamicConfig {
             PrintWriter printWriter = new PrintWriter(fstream);\r
             printWriter.print(indentedretstring);\r
             printWriter.close();\r
+            fstream.close();\r
             \r
             debugLogger.info("New Config successfully written to local file to " + configFile);\r
         } catch (IOException e) {\r
@@ -176,7 +177,7 @@ public class FetchDynamicConfig {
             file = ResourceUtils.getFile("classpath:" + configFileName);\r
             content = new String(Files.readAllBytes(file.toPath()));\r
         } catch (FileNotFoundException e) {\r
-            errorLogger.error("colud not find file :", file.getName());\r
+            errorLogger.error("colud not find file :",configFileName);\r
             \r
         } catch (IOException e) {\r
             errorLogger.error("unable to read the file , reason:", e.getCause());\r