Skip to content

Commit

Permalink
#141 DefaultResourceLoader uses ClassLoader.getSystemResourceAsStream…
Browse files Browse the repository at this point in the history
…() as fallback

This should be no change when using "normal" Config/Configuration but allows users
of the ConfigurationBuilder to have this fallback to ClassLoader.getSystemResourceAsStream()
when the resource is not found via the usual getClass().getResourceAsStream()
  • Loading branch information
rbygrave committed May 6, 2024
1 parent dc1a1ab commit fd26e44
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ final class DefaultResourceLoader implements ResourceLoader {

@Override
public InputStream getResourceAsStream(String resourcePath) {
return getClass().getResourceAsStream("/" + resourcePath);
var is = getClass().getResourceAsStream("/" + resourcePath);
if (is == null) {
// search the module path for top level resource
is = ClassLoader.getSystemResourceAsStream(resourcePath);
}
return is;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,7 @@ InputStream resource(String resourcePath, InitialLoader.Source source) {
}

private InputStream resourceStream(String resourcePath) {
InputStream is = resourceLoader.getResourceAsStream(resourcePath);
if (is == null) {
// search the module path for top level resource
is = ClassLoader.getSystemResourceAsStream(resourcePath);
}
return is;
return resourceLoader.getResourceAsStream(resourcePath);
}

/**
Expand Down

0 comments on commit fd26e44

Please sign in to comment.