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

RelaxedDataBinder does not bind values that are only defined in environment variable style #98

Closed
nebhale opened this issue Oct 26, 2013 · 0 comments

Comments

@nebhale
Copy link
Member

nebhale commented Oct 26, 2013

I'm attempting to map the value of the environment variable GITHUB_CLIENT_ID onto an @ConfigurationProperties class as defined below:

@ConfigurationProperties(name = "github", ignoreUnknownFields = false)
public final class GitHubProperties {

    private volatile Client client = new Client();

    public Client getClient() { return this.client; }
    public void setClient(Client client) { this.client = client; }

    public static class Client {

        private volatile String id = "";
        private volatile String secret = "";

        public String getId() { return this.id; }
        public void setId(String id) { this.id = id; }

        public String getSecret() { return this.secret; }
        public void setSecret(String secret) { this.secret = secret; }
    }

}

Currently, the value of the environment variable is not bound correctly. However, if I set the property in application.yml it does.

---
github:
  client:
    id: dummy-id

The weird thing is that the value that is bound is the value from the environment not from the application.yml file. I believe I've traced the bug to the RelaxedDataBinder.getProperyValuesForNamePrefix() method. The method attempts to find the candidate keys for bind, but does so by scanning for methods staring with <name>.. In my case it's looking for github. which doesn't exist until I create that key in the application.yml.

screen shot 2013-10-26 at 10 39 04

Once it's found the candidate key though, it seems to do the "relaxed" binding just fine.

I believe that a change needs to be made to use the "relaxed" key matching algorithm when searching for the candidate keys.

@dsyer dsyer closed this as completed in 8d18694 Oct 28, 2013
gigfork pushed a commit to boostrack/spring-boot that referenced this issue Apr 21, 2014
RelaxedDataBinder now supports "env var" style variables that include the
path prefix, e.g. FOO_BAR_BAZ=boom will bind to a bean with property "baz"
and a binder with prefix "foo.bar".

Fixes spring-projectsgh-98
snicoll pushed a commit that referenced this issue Jul 28, 2017
This commit makes sure that the Liquibase endpoint uses the configured
schema.

See gh-98£62
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant