summaryrefslogtreecommitdiffstats
path: root/common/onap-common-configuration-management/onap-configuration-management-core/src/main
diff options
context:
space:
mode:
authorDmitry Puzikov <d.puzikov2@partner.samsung.com>2019-11-19 15:13:23 +0100
committerOfir Sonsino <ofir.sonsino@intl.att.com>2019-11-21 15:36:52 +0000
commit30510151ca3575cb079aba0ea34567add7c52526 (patch)
treeba09de666cb3b189b7057559efeddc1b56b0e716 /common/onap-common-configuration-management/onap-configuration-management-core/src/main
parent8b0c94492906d7db528af73834c0d2299b8eb382 (diff)
Fixing sonar issues
Replaced URL with URI to avoid trigger DNS. Change-Id: If85f1f2780c46e0966f3707af51571f4a7aa2f15 Issue-ID: SDC-2660 Signed-off-by: Dmitry Puzikov <d.puzikov2@partner.samsung.com>
Diffstat (limited to 'common/onap-common-configuration-management/onap-configuration-management-core/src/main')
-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);
}
}
}