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

Config.Builder ignores explicit ordering of systemProperties() and environmentVariables() #977

Closed
pfmackin opened this issue Aug 30, 2019 · 0 comments · Fixed by #1002
Closed
Assignees

Comments

@pfmackin
Copy link
Contributor

Helidon Version: 1.2.1

Helidon MP

JDK version: 1.8.0_211

OS: MacOS 10.13.6

Problem Description:
Config.Builder ignores explicit ordering of systemProperties() and environmentVariables().
When systemProperties() is before environmentVariables(), the env vars still take precedence.

Note: The Helidon Javadoc documents that the ordering of sources establishes precedence. See Config.Buider at https://helidon.io/docs/latest/apidocs/index.html?overview-summary.html

Steps to reproduce:

  1. Create a a project using MP archetype to test this.

  2. Change app.greeting to appGreeting in GreetingProvider.java and META-INF/microprofile-config.properties.

  3. Change Main.java as follows:

    static Server startServer() {

     return Server.builder()
         .config(Config.builder()
             .sources(
                 systemProperties(),
                 environmentVariables(),
                 classpath("META-INF/microprofile-config.properties"))
             .build())
         .build()
         .start();
    
  4. Build and run the application as follows:
    export appGreeting=HelloFromEnvironment
    mvn package -DskipTests=true
    java -DappGreeting="HelloFromJavaProperty" -jar target/helidon-quickstart-mp.jar

  5. Test the app

curl http://localhost:8080/greet
{"message":"HelloFromEnvironment World!"}

@batsatt batsatt self-assigned this Sep 6, 2019
batsatt added a commit to batsatt/helidon that referenced this issue Sep 6, 2019
batsatt added a commit that referenced this issue Sep 9, 2019
* Fix precedence for explicit sys prop and env var sources.
Fixes #977.

* Introduce explicit types for sys props and env vars config sources.

* Copyright fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants