From 1cbcf8ee77b394cd0f4e896197e24f09acef5861 Mon Sep 17 00:00:00 2001 From: Dmitry Puzikov Date: Thu, 28 Nov 2019 14:33:24 +0100 Subject: Logged all caught exceptions Fix sonar issue related to logging caught exceptions. Change-Id: I61b2106165a81f3b2f0f9cc0da5911787504f50e Issue-ID: SDC-2698 Signed-off-by: Dmitry Puzikov --- .../org/onap/config/impl/ConfigurationImpl.java | 35 ++++++++++++++++++---- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/ConfigurationImpl.java') diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/ConfigurationImpl.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/ConfigurationImpl.java index 9a3fbd26fb..d13d5f7b92 100644 --- a/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/ConfigurationImpl.java +++ b/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/ConfigurationImpl.java @@ -39,9 +39,13 @@ import org.onap.config.Constants; import org.onap.config.NonConfigResource; import org.onap.config.api.Config; import org.onap.config.api.Hint; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ConfigurationImpl implements org.onap.config.api.Configuration { + private static final Logger LOGGER = LoggerFactory.getLogger(ConfigurationImpl.class); + private static final String KEY_CANNOT_BE_NULL = "Key can't be null."; private static final NonConfigResource NON_CONFIG_RESOURCE = new NonConfigResource(); @@ -51,7 +55,7 @@ public class ConfigurationImpl implements org.onap.config.api.Configuration { try { init(); } catch (ConfigurationException e) { - throw new IllegalStateException("Failed to initialize configuration"); + throw new IllegalStateException("Failed to initialize configuration", e); } } @@ -214,7 +218,14 @@ public class ConfigurationImpl implements org.onap.config.api.Configuration { } } } catch (Exception e) { - e.printStackTrace(); + LOGGER.warn( + "Couldn't populate map fot tenant: {}, namespace: {}, key: {}, type: {}", + tenantId, + namespace, + key, + clazz.getSimpleName(), + e + ); } return map; } @@ -262,7 +273,13 @@ public class ConfigurationImpl implements org.onap.config.api.Configuration { map.put(k, value); } } catch (Exception e) { - e.printStackTrace(); + LOGGER.warn( + "Couldn't generate map fot tenant: {}, namespace: {}, key: {}", + tenantId, + namespace, + key, + e + ); } return parentMap; } @@ -336,7 +353,14 @@ public class ConfigurationImpl implements org.onap.config.api.Configuration { + "class decorated with @org.openecomp.config.api.Config are allowed as argument."); } } catch (Exception exception) { - exception.printStackTrace(); + LOGGER.warn( + "Failed to get internal value fot tenant: {}, namespace: {}, key: {}, type: {}", + tenant, + namespace, + key, + clazz.getSimpleName(), + exception + ); } return null; } @@ -422,6 +446,7 @@ public class ConfigurationImpl implements org.onap.config.api.Configuration { try { return clazz.getDeclaredConstructor(classes); } catch (Exception exception) { + LOGGER.warn("Failed to get {} constructor.", clazz.getSimpleName(), exception); return null; } } @@ -546,7 +571,7 @@ public class ConfigurationImpl implements org.onap.config.api.Configuration { collection.add(type1); } } catch (RuntimeException re) { - // do nothing + LOGGER.warn("Failed to convert {}", commaSeparatedValues, re); } } return collection; -- cgit 1.2.3-korg