diff --git a/avaje-config/src/main/java/io/avaje/config/CoreEntry.java b/avaje-config/src/main/java/io/avaje/config/CoreEntry.java index 81b7e82a..45dfc7bf 100644 --- a/avaje-config/src/main/java/io/avaje/config/CoreEntry.java +++ b/avaje-config/src/main/java/io/avaje/config/CoreEntry.java @@ -188,7 +188,7 @@ void put(String key, CoreEntry value) { entryMap.put(key, value); } - void put(String key, String value, String source) { + void put(String key, @Nullable String value, String source) { entryMap.put(key, CoreEntry.of(value, source)); } diff --git a/avaje-config/src/main/java/io/avaje/config/InitialLoadContext.java b/avaje-config/src/main/java/io/avaje/config/InitialLoadContext.java index 5c0fbd90..6e26cda1 100644 --- a/avaje-config/src/main/java/io/avaje/config/InitialLoadContext.java +++ b/avaje-config/src/main/java/io/avaje/config/InitialLoadContext.java @@ -88,14 +88,14 @@ InputStream resource(String resourcePath, InitialLoader.Source source) { if (source == InitialLoader.Source.RESOURCE) { is = resourceStream(resourcePath); if (is != null) { - loadedResources.add("resource:" + resourcePath); + loadedResources.add(source.key(resourcePath)); } } else { File file = new File(resourcePath); if (file.exists()) { try { is = new FileInputStream(file); - loadedResources.add("file:" + resourcePath); + loadedResources.add(source.key(resourcePath)); loadedFiles.add(file); } catch (FileNotFoundException e) { throw new UncheckedIOException(e); diff --git a/avaje-config/src/main/java/io/avaje/config/InitialLoader.java b/avaje-config/src/main/java/io/avaje/config/InitialLoader.java index dbfa651d..daa8244a 100644 --- a/avaje-config/src/main/java/io/avaje/config/InitialLoader.java +++ b/avaje-config/src/main/java/io/avaje/config/InitialLoader.java @@ -35,7 +35,10 @@ static Configuration.ExpressionEval evalFor(Properties properties) { enum Source { RESOURCE, - FILE + FILE; + String key(String path) { + return name().toLowerCase() + ':' + path; + } } private final ConfigurationLog log; @@ -298,7 +301,7 @@ private boolean loadCustom(String resourcePath, Source source) { boolean loadCustomExtension(String resourcePath, ConfigParser parser, Source source) { try (InputStream is = resource(resourcePath, source)) { if (is != null) { - var sourceName = (source == RESOURCE ? "resource:" : "file:") + resourcePath; + var sourceName = source.key(resourcePath); parser.load(is).forEach((k, v) -> loadContext.put(k, v, sourceName)); return true; } @@ -311,7 +314,7 @@ boolean loadCustomExtension(String resourcePath, ConfigParser parser, Source sou boolean loadProperties(String resourcePath, Source source) { try (InputStream is = resource(resourcePath, source)) { if (is != null) { - loadProperties(is, (source == RESOURCE ? "resource:" : "file") + resourcePath); + loadProperties(is, source.key(resourcePath)); return true; } } catch (IOException e) {