summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArindam Mondal <arind.mondal@samsung.com>2020-03-10 12:07:39 +0900
committerarindamm <arind.mondal@samsung.com>2020-03-10 12:08:00 +0900
commit730394dcfbc41a0142b2c3649e673579fb891a6d (patch)
tree73d0a90f9dd56baae044eac4d260b657f367aaf9
parentfa37b982bc105c9c7b86b6821b0c15f0d1fe4f50 (diff)
Sonar fix tr-with-resources
Issue-ID: OPTFRA-714 Sonar link: https://sonar.onap.org/code?id=org.onap.fgps%3Afgps&selected=org.onap.fgps%3Afgps-api%3Asrc%2Fmain%2Fjava%2Forg%2Fonap%2Ffgps%2Fapi%2Feelf%2Fconfiguration%2FEELFManager.java Use try with resources Change-Id: I9f5fafa6c8511b8aed4293f93a0853a9b7dcdd62 Signed-off-by: arindamm <arind.mondal@samsung.com>
-rw-r--r--valetapi/src/main/java/org/onap/fgps/api/eelf/configuration/EELFManager.java17
1 files changed, 4 insertions, 13 deletions
diff --git a/valetapi/src/main/java/org/onap/fgps/api/eelf/configuration/EELFManager.java b/valetapi/src/main/java/org/onap/fgps/api/eelf/configuration/EELFManager.java
index feb98f9..a096748 100644
--- a/valetapi/src/main/java/org/onap/fgps/api/eelf/configuration/EELFManager.java
+++ b/valetapi/src/main/java/org/onap/fgps/api/eelf/configuration/EELFManager.java
@@ -312,24 +312,15 @@ public final class EELFManager {
String msg = EELFResourceManager.getMessage(EELFMsgs.LOADING_LOG_CONFIGURATION,file.getAbsolutePath());
delayedLogging.add(msg);
- BufferedInputStream stream = null;
- try {
- stream = new BufferedInputStream(new FileInputStream(file));
+ try (BufferedInputStream stream = new BufferedInputStream(new FileInputStream(file));){
delayedLogging.add(String.format("EELF000I Loading logging configuration from %s",
file.getAbsolutePath()));
loadLoggingConfiguration(stream, delayedLogging);
} catch (FileNotFoundException e) {
delayedLogging.add(EELFResourceManager.format(e));
- } finally {
- if (stream != null) {
- try {
- stream.close();
- } catch (IOException e) {
- // not much we can do since logger may not be configured yet
- e.printStackTrace(System.out);
- }
- }
- }
+ } catch (IOException e1) {
+ delayedLogging.add(EELFResourceManager.format(e1));
+ }
return true;
}