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

PAYARA-3950 Process all properties files #4050

Merged
merged 2 commits into from
Jun 19, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import java.lang.reflect.Type;
import java.net.InetAddress;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
Expand Down Expand Up @@ -410,14 +411,15 @@ private void initialiseApplicationConfig(ApplicationInfo info) {
info.addTransientAppMetaData(APP_METADATA_KEY, appConfigProperties);
try {
// Read application defined properties and add as transient metadata
appConfigProperties.add(getPropertiesFromFile(info.getAppClassLoader(), "META-INF/microprofile-config.properties"));
appConfigProperties.add(getPropertiesFromFile(info.getAppClassLoader(), "../../META-INF/microprofile-config.properties"));
appConfigProperties.addAll(getPropertiesFromFile(info.getAppClassLoader(), "META-INF/microprofile-config.properties"));
appConfigProperties.addAll(getPropertiesFromFile(info.getAppClassLoader(), "../../META-INF/microprofile-config.properties"));
} catch (IOException ex) {
Logger.getLogger(ConfigProviderResolverImpl.class.getName()).log(Level.SEVERE, null, ex);
}
}

private Properties getPropertiesFromFile(ClassLoader appClassLoader, String fileName) throws IOException {
private List<Properties> getPropertiesFromFile(ClassLoader appClassLoader, String fileName) throws IOException {
List<Properties> props = new ArrayList<>();
// Read application defined properties and add as transient metadata
Enumeration<URL> resources = appClassLoader.getResources(fileName);
while (resources.hasMoreElements()) {
Expand All @@ -426,9 +428,9 @@ private Properties getPropertiesFromFile(ClassLoader appClassLoader, String file
try (InputStream is = url.openStream()) {
p.load(url.openStream());
Copy link
Contributor

@svendiedrichsen svendiedrichsen Jun 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this call twice to url.openStream intentional or should the variable is be used instead of the second call?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clearly I was so focused on fixing my problem I didn't review the code for additional issues!

}
return p;
props.add(p);
}
return new Properties();
return props;
}

}