Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent circular load.properties #178

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
11 changes: 8 additions & 3 deletions avaje-config/src/main/java/io/avaje/config/InitialLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ enum Source {
private final ConfigurationLog log;
private final InitialLoadContext loadContext;
private final Set<String> profileResourceLoaded = new HashSet<>();
private final Set<String> loadProperties = new HashSet<>();
private final Parsers parsers;

InitialLoader(CoreComponents components, ResourceLoader resourceLoader) {
Expand Down Expand Up @@ -188,12 +189,14 @@ private boolean loadTest() {
}

/**
* Load configuration defined by a <em>load.properties</em> entry in properties file.
* Recursively Load configuration defined by a <em>load.properties</em> entry in properties file.
*/
private void loadViaIndirection() {
String paths = loadContext.indirectLocation();
SentryMan marked this conversation as resolved.
Show resolved Hide resolved
if (paths != null) {
if (paths != null && !loadProperties.contains(paths)) {
SentryMan marked this conversation as resolved.
Show resolved Hide resolved
loadViaPaths(paths);
SentryMan marked this conversation as resolved.
Show resolved Hide resolved
loadProperties.add(paths);
loadViaIndirection();
}
}

Expand All @@ -220,7 +223,9 @@ private void loadViaProfiles(Source source) {

private void loadViaPaths(String paths) {
for (String path : splitPaths(paths)) {
loadWithExtensionCheck(loadContext.eval(path));
if (loadProperties.add(path)) {
loadWithExtensionCheck(loadContext.eval(path));
}
}
}

Expand Down