summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/NonConfigResource.java28
1 files changed, 17 insertions, 11 deletions
diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/NonConfigResource.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/NonConfigResource.java
index 459c8b476b..065e7f42b4 100644
--- a/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/NonConfigResource.java
+++ b/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/NonConfigResource.java
@@ -17,6 +17,7 @@
package org.onap.config;
import java.io.File;
+import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
@@ -36,9 +37,9 @@ public class NonConfigResource {
static final String CONFIG_LOCATION = "config.location";
private final List<Function<String, Path>> lookupFunctions =
- Arrays.asList(this::getFromFile, this::findInFiles, this::getForNode, this::getGlobal, this::findInUrls);
+ Arrays.asList(this::getFromFile, this::findInFiles, this::getForNode, this::getGlobal, this::findInUris);
- private final Set<URL> urls = Collections.synchronizedSet(new HashSet<>());
+ private final Set<URI> uris = Collections.synchronizedSet(new HashSet<>());
private final Set<File> files = Collections.synchronizedSet(new HashSet<>());
private final Function<String, String> propertyGetter;
@@ -52,7 +53,7 @@ public class NonConfigResource {
}
public void add(URL url) {
- urls.add(url);
+ uris.add(toUri(url));
}
public void add(File file) {
@@ -96,15 +97,12 @@ public class NonConfigResource {
return new File(resource).exists() ? Paths.get(resource) : null;
}
- private Path findInUrls(String resource) {
-
- for (URL url : urls) {
-
- if (url.getFile().endsWith(resource)) {
- return Paths.get(toUri(url));
+ private Path findInUris(String resource) {
+ for (URI uri : uris) {
+ if (toUrl(uri).getFile().endsWith(resource)) {
+ return Paths.get(uri);
}
}
-
return null;
}
@@ -139,7 +137,15 @@ public class NonConfigResource {
try {
return url.toURI();
} catch (URISyntaxException e) {
- throw new IllegalStateException("Unexpected URL syntax: " + url.toString(), e);
+ throw new IllegalStateException("Unexpected URL syntax: " + url, e);
+ }
+ }
+
+ private static URL toUrl(URI uri) {
+ try {
+ return uri.toURL();
+ } catch (MalformedURLException e) {
+ throw new IllegalStateException("Unexpected URI syntax: " + uri, e);
}
}
}