-
Notifications
You must be signed in to change notification settings - Fork 567
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
Config.Builder and Config.create() give environment variables precedence over system properties #976
Comments
There are a couple of things going on here... First, the Second, sys prop and env var precedence is inverted in SE relative to MP (see #507). Taken together with the above, the behavior you are seeing is actually expected, but… confusing, for sure. IMO, aligning the default behavior in SE with MP is the right approach, but it is a breaking change. We can certainly consider doing this for the next major release. |
You should have the option to define order of env and sys properties (another issue & PR I think).
This is in the order of how hard it is to change these
So the ordering is logical and from my point of view the reasoning is sound. Unfortunately the MicroProfile specification has decided to use a different order - they consider system properties are more significant than environment variables. You have the option to use both - either MP approach or Helidon approach. |
Even if I explicitly order them with system properties first, the env vars take precedence: see issue 977. It would be good if you could fix that. Note, that meta-config works correctly. The precedence follows the order of appearance, e.g. I can make system properties have the highest precedence. |
In progress, see PR #1002. |
Helidon Version: 1.2.1
Helidon MP and SE
JDK version: 1.8.0_211
OS: MacOS 10.13.6
Problem Description :
The Config.Builder and Config.create() give environment variables precedence over system properties. The config spec has the opposite. See https://download.eclipse.org/microprofile/microprofile-config-1.3/microprofile-config-spec.pdf
Note: The Helidon Javadoc actually documents this incorrect behavior: See Config.Buider at https://helidon.io/docs/latest/apidocs/index.html?overview-summary.html
Furthermore, If the Server is created without using the Config.Builder then the behavior is correct. This works:
static Server startServer() {
return Server.create().start();
}
Steps to reproduce :
Create a a project using MP archetype to test this.
export appGreeting=HelloFromEnvironment
mvn package -DskipTests=true
java -DappGreeting="HelloFromJavaProperty" -jar target/helidon-quickstart-mp.jar
curl http://localhost:8080/greet
{"message":"HelloFromJavaProperty World!"}
Now change Main.java as follows:
Retest the app and you will see the problem:
curl http://localhost:8080/greet
{"message":"HelloFromEnvironment World!"}
The text was updated successfully, but these errors were encountered: