summaryrefslogtreecommitdiffstats
path: root/common/onap-common-configuration-management/onap-configuration-management-api/src/main
diff options
context:
space:
mode:
authorDmitry Puzikov <d.puzikov2@partner.samsung.com>2019-11-21 15:44:17 +0100
committerOfir Sonsino <ofir.sonsino@intl.att.com>2019-12-01 15:45:34 +0000
commit57c8700a4808665d5005de583a15354b9fb0b9f8 (patch)
treea57a8b871948674419309e30944a3f12ead01880 /common/onap-common-configuration-management/onap-configuration-management-api/src/main
parentd6890fce461c040c2776dfdedd47be282a29f877 (diff)
Fix sonar issue with test coverage
Added tests to cover the case. Fixed provider load failure: If more than one provider is configured and if the first if failng try to load next one. Change-Id: Idd7edb90e2b9b1cf21ec20e299140d3362bd1138 Issue-ID: SDC-2693 Signed-off-by: Dmitry Puzikov <d.puzikov2@partner.samsung.com>
Diffstat (limited to 'common/onap-common-configuration-management/onap-configuration-management-api/src/main')
-rw-r--r--common/onap-common-configuration-management/onap-configuration-management-api/src/main/java/org/onap/config/api/ConfigurationLoader.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/common/onap-common-configuration-management/onap-configuration-management-api/src/main/java/org/onap/config/api/ConfigurationLoader.java b/common/onap-common-configuration-management/onap-configuration-management-api/src/main/java/org/onap/config/api/ConfigurationLoader.java
index 8d61701a9c..78f8b23024 100644
--- a/common/onap-common-configuration-management/onap-configuration-management-api/src/main/java/org/onap/config/api/ConfigurationLoader.java
+++ b/common/onap-common-configuration-management/onap-configuration-management-api/src/main/java/org/onap/config/api/ConfigurationLoader.java
@@ -17,6 +17,7 @@
package org.onap.config.api;
import java.util.Iterator;
+import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
/**
@@ -34,8 +35,12 @@ class ConfigurationLoader {
ServiceLoader<ConfigurationManager> loader = ServiceLoader.load(ConfigurationManager.class);
Iterator<ConfigurationManager> configManagers = loader.iterator();
- if (configManagers.hasNext()) {
- return configManagers.next();
+ while (configManagers.hasNext()) {
+ try {
+ return configManagers.next();
+ } catch (ServiceConfigurationError e) {
+ // this provider loading has failed, let's try next one
+ }
}
throw new IllegalStateException("No binding found for configuration service");