diff options
author | Arun S. Yerra <arun.yerra@huawei.com> | 2017-09-07 16:21:23 -0700 |
---|---|---|
committer | Arun S. Yerra <arun.yerra@huawei.com> | 2017-09-07 16:25:35 -0700 |
commit | f28ba9bec18a636a9d5ecb38851f8af973e91f63 (patch) | |
tree | b3d1c2e48960911e52b102bc3b6ad02351002fe7 /sli/recording/src | |
parent | 606202a9854c74b98f31d10b72f0875bb0a42924 (diff) |
Fix sonar blocker issues in ccsdk/core module
Sonarqube report for CCSDK core identfied some blcoker issues. This fix addresses those bugs.
Issue-Id: CCSDK-84
Change-Id: Ie6ff19b7b0815a129f9809243e8e3eb0a64144ab
Signed-off-by: Arun S. Yerra <arun.yerra@huawei.com>
Diffstat (limited to 'sli/recording/src')
-rw-r--r-- | sli/recording/src/main/java/org/onap/ccsdk/sli/core/sli/recording/FileRecorder.java | 12 |
1 files changed, 11 insertions, 1 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 1143ef74..4a60de95 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 @@ -24,6 +24,7 @@ package org.onap.ccsdk.sli.core.sli.recording; import java.io.File; import java.io.FileWriter; import java.io.PrintWriter; +import java.io.IOException; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; @@ -82,6 +83,7 @@ public class FileRecorder implements SvcLogicRecorder { File recordFile = new File(fileName); PrintWriter recPrinter = null; + FileWriter fileWriter = null; Date now = new Date(); TimeZone tz = TimeZone.getTimeZone("UTC"); @@ -95,7 +97,7 @@ public class FileRecorder implements SvcLogicRecorder { try { - recPrinter = new PrintWriter(new FileWriter(recordFile, true)); + recPrinter = new PrintWriter(fileWriter = new FileWriter(recordFile, true)); recPrinter.println(record); } catch (Exception e) @@ -108,6 +110,14 @@ public class FileRecorder implements SvcLogicRecorder { { recPrinter.close(); } + if (fileWriter != null) + { + try { + fileWriter.close(); + } catch (IOException e) { + + } + } } |