aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsurya-huawei <a.u.surya@huawei.com>2017-09-17 22:53:41 +0530
committersurya-huawei <a.u.surya@huawei.com>2017-09-17 23:00:18 +0530
commit148c15b82dfc2025dc1c4a19b55293cdf3e9db2f (patch)
tree1d595aa9bab5c7a3868b639b7bc81e8cbbe25a67
parente9d594cf137feb3c9d74b30587d1bf30b349a9e7 (diff)
Fix Sonar issues in sli/core module
One major issue * Use try with resources instead of try Issue-Id: CCSDK-87 Change-Id: Ic30016f70ebc355f80a73c9e4632b7971d2b87be Signed-off-by: surya-huawei <a.u.surya@huawei.com>
-rw-r--r--sli/recording/src/main/java/org/onap/ccsdk/sli/core/sli/recording/FileRecorder.java10
1 files changed, 2 insertions, 8 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 4a60de95..772906e5 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);
- PrintWriter recPrinter = null;
FileWriter fileWriter = null;
Date now = new Date();
@@ -94,10 +93,9 @@ public class FileRecorder implements SvcLogicRecorder {
record = record.replaceFirst("__TIMESTAMP__", dateFmt.format(now));
}
- try
+ try ( PrintWriter recPrinter = new PrintWriter(fileWriter = new
+ FileWriter(recordFile, true)))
{
-
- recPrinter = new PrintWriter(fileWriter = new FileWriter(recordFile, true));
recPrinter.println(record);
}
catch (Exception e)
@@ -106,10 +104,6 @@ public class FileRecorder implements SvcLogicRecorder {
}
finally
{
- if (recPrinter != null)
- {
- recPrinter.close();
- }
if (fileWriter != null)
{
try {