From 6945b75aac0e6bc2bad6f824769b32842f06bc46 Mon Sep 17 00:00:00 2001 From: Liard Samuel Date: Fri, 8 Oct 2021 09:21:18 +0200 Subject: Fix sonar Security Hotspots Issue-ID: CCSDK-3491 Signed-off-by: sliard Change-Id: I33787ccca2a8acd8085db6b2a915e8f2ac2511ec Signed-off-by: Dan Timoney Signed-off-by: highstreetherbert --- .../org/onap/ccsdk/features/lib/npm/api/NpmServiceManagerImpl.java | 4 +++- .../src/main/java/org/onap/ccsdk/features/lib/npm/utils/NpmUtils.java | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/network-prioritization') diff --git a/lib/network-prioritization/src/main/java/org/onap/ccsdk/features/lib/npm/api/NpmServiceManagerImpl.java b/lib/network-prioritization/src/main/java/org/onap/ccsdk/features/lib/npm/api/NpmServiceManagerImpl.java index 2cdef3537..9016579bc 100644 --- a/lib/network-prioritization/src/main/java/org/onap/ccsdk/features/lib/npm/api/NpmServiceManagerImpl.java +++ b/lib/network-prioritization/src/main/java/org/onap/ccsdk/features/lib/npm/api/NpmServiceManagerImpl.java @@ -415,7 +415,9 @@ public class NpmServiceManagerImpl implements NpmServiceManager { try { logger.trace("Initializing NPM Configurations from:({})", configFilePath); if (new File(configFilePath).exists()) { - npmConfigurations.load(new FileInputStream(configFilePath)); + try (FileInputStream configInputStream = new FileInputStream(configFilePath)) { + npmConfigurations.load(configInputStream); + } } else { logger.warn("Config File:({}) not found, Initializing NPM with default configurations.", configFilePath); configFilePath = "properties" + File.separator + NpmConstants.NPM_CONFIG_PROPERTIES_FILE_NAME; diff --git a/lib/network-prioritization/src/main/java/org/onap/ccsdk/features/lib/npm/utils/NpmUtils.java b/lib/network-prioritization/src/main/java/org/onap/ccsdk/features/lib/npm/utils/NpmUtils.java index 735d6d91f..8b74e318b 100644 --- a/lib/network-prioritization/src/main/java/org/onap/ccsdk/features/lib/npm/utils/NpmUtils.java +++ b/lib/network-prioritization/src/main/java/org/onap/ccsdk/features/lib/npm/utils/NpmUtils.java @@ -61,7 +61,7 @@ public class NpmUtils { mapper.enable(SerializationFeature.INDENT_OUTPUT); return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(instance); } catch (JsonProcessingException e) { - e.printStackTrace(); + logger.warn(e.getMessage(), e); } return null; } -- cgit 1.2.3-korg