Fixing sonar issues 75/98375/3
authorDmitry Puzikov <d.puzikov2@partner.samsung.com>
Wed, 13 Nov 2019 15:52:25 +0000 (16:52 +0100)
committerOfir Sonsino <ofir.sonsino@intl.att.com>
Sun, 17 Nov 2019 14:17:17 +0000 (14:17 +0000)
Added logging instead of skipping or printing stacktraces.

Change-Id: I258a2a76c295f12b30e200c4519bc1bb0741f642
Issue-ID: SDC-2654
Signed-off-by: Dmitry Puzikov <d.puzikov2@partner.samsung.com>
common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/ConfigurationUtils.java

index 991ec5f..6adeb2d 100644 (file)
@@ -205,7 +205,7 @@ public class ConfigurationUtils {
                 try {
                     return Enum.valueOf(ConfigurationMode.class, modeName);
                 } catch (Exception exception) {
-                    //do nothing
+                    LOGGER.debug("Configuration mode for merge strategy '{}' not found", modeName, exception);
                 }
             }
         }
@@ -231,7 +231,7 @@ public class ConfigurationUtils {
                     throw new ConfigurationException(CONFIGURATION_TYPE_NOT_SUPPORTED + configType);
             }
         } catch (ConfigurationException exception) {
-            exception.printStackTrace();
+            LOGGER.error("Error reading configuration at {}.", url.toString(), exception);
         }
 
         return Optional.empty();
@@ -263,7 +263,7 @@ public class ConfigurationUtils {
         try {
             configurationMode = ConfigurationMode.valueOf(configMode);
         } catch (Exception exception) {
-            LOGGER.error("Could not find convert {} into configuration mode", configMode);
+            LOGGER.error("Could not find convert {} into configuration mode.", configMode, exception);
         }
         return Optional.ofNullable(configurationMode);
     }
@@ -457,7 +457,7 @@ public class ConfigurationUtils {
                 return IOUtils.toString(new URL(path), Charset.defaultCharset());
             }
         } catch (Exception exception) {
-            exception.printStackTrace();
+            LOGGER.error("Error while getting '{}' content", path, exception);
         }
         return null;
     }
@@ -468,7 +468,7 @@ public class ConfigurationUtils {
                 return new String(Files.readAllBytes(path));
             }
         } catch (Exception exception) {
-            exception.printStackTrace();
+            LOGGER.error("Error while getting '{}' content", path.toString(), exception);
         }
         return null;
     }