summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorParshad Patel <pars.patel@samsung.com>2018-11-07 15:58:19 +0900
committerParshad Patel <pars.patel@samsung.com>2018-11-19 15:28:50 +0900
commit3e64dafb04f0f7d40613bcc67efbe999ed132b47 (patch)
tree3a21852c4a32602a87ef89258c1c36ab4d6240a9
parent28e2e1ca2a9c9d1df3e2b3ab69c0aecbb62918bd (diff)
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>
-rw-r--r--sli/recording/src/main/java/org/onap/ccsdk/sli/core/sli/recording/FileRecorder.java18
1 files changed, 2 insertions, 16 deletions
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 772906e59..ac3dbd2a9 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 @@ public class FileRecorder implements SvcLogicRecorder {
}
File recordFile = new File(fileName);
- FileWriter fileWriter = null;
Date now = new Date();
TimeZone tz = TimeZone.getTimeZone("UTC");
@@ -93,8 +92,8 @@ public class FileRecorder implements SvcLogicRecorder {
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 @@ public class FileRecorder implements SvcLogicRecorder {
{
throw new SvcLogicException("Cannot write record to file", e);
}
- finally
- {
- if (fileWriter != null)
- {
- try {
- fileWriter.close();
- } catch (IOException e) {
-
- }
- }
- }
-
-
}
}