Fix blocker sonar issue in sli/core
Fix use try with resources issue in FileRecorder.java
Issue-ID: CCSDK-647
Change-Id: Ibe8afb5873b3af681def5310cc53ea0172608f1a
Signed-off-by: Parshad Patel <pars.patel@samsung.com>
diff --git a/sli/recording/src/main/java/org/onap/ccsdk/sli/core/sli/recording/FileRecorder.java b/sli/recording/src/main/java/org/onap/ccsdk/sli/core/sli/recording/FileRecorder.java
index 772906e..ac3dbd2 100644
--- a/sli/recording/src/main/java/org/onap/ccsdk/sli/core/sli/recording/FileRecorder.java
+++ b/sli/recording/src/main/java/org/onap/ccsdk/sli/core/sli/recording/FileRecorder.java
@@ -82,7 +82,6 @@
}
File recordFile = new File(fileName);
- FileWriter fileWriter = null;
Date now = new Date();
TimeZone tz = TimeZone.getTimeZone("UTC");
@@ -93,8 +92,8 @@
record = record.replaceFirst("__TIMESTAMP__", dateFmt.format(now));
}
- try ( PrintWriter recPrinter = new PrintWriter(fileWriter = new
- FileWriter(recordFile, true)))
+ try ( FileWriter fileWriter = new FileWriter(recordFile, true);
+ PrintWriter recPrinter = new PrintWriter(fileWriter))
{
recPrinter.println(record);
}
@@ -102,19 +101,6 @@
{
throw new SvcLogicException("Cannot write record to file", e);
}
- finally
- {
- if (fileWriter != null)
- {
- try {
- fileWriter.close();
- } catch (IOException e) {
-
- }
- }
- }
-
-
}
}