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

Wildcard config file locations from the working directory override each other #24428

Closed
gilles-gosuin opened this issue Dec 10, 2020 · 4 comments
Assignees
Labels
type: regression A regression from a previous release
Milestone

Comments

@gilles-gosuin
Copy link

After some more debugging, I'm pretty much convinced that something fishy is going on so I'm taking the liberty to submit a formal issue here, since I'm not getting any relevant answer on StackOverflow.

In addition to the snippets on SO, please find attached the whole Gradle project, for your convenience.

composite-properties.zip

My environment:

  • macOS 11.0.1 (Big Sur)
  • Spring Boot 2.4.0

$ java -version
openjdk version "15.0.1" 2020-10-20
OpenJDK Runtime Environment (build 15.0.1+9-18)
OpenJDK 64-Bit Server VM (build 15.0.1+9-18, mixed mode, sharing)

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 10, 2020
@wilkinsona
Copy link
Member

wilkinsona commented Dec 10, 2020

Thanks for the sample. This appears to be a regression in Spring Boot 2.4.0. 2.3.5.RELEASE logs the following on startup:

2020-12-10 09:21:25.611  INFO 77998 --- [           main] compositeproperties.Application          : composite-properties are : CompositeProperties(fromFirstFile={it=works}, fromSecondFile={it=works})

Whereas 2.4.0 logs the following:

2020-12-10 09:22:11.252  INFO 78203 --- [           main] compositeproperties.Application          : composite-properties are : CompositeProperties(fromFirstFile={it=works}, fromSecondFile={})

@wilkinsona wilkinsona added type: regression A regression from a previous release and removed status: waiting-for-triage An issue we've not yet triaged labels Dec 10, 2020
@wilkinsona wilkinsona added this to the 2.4.x milestone Dec 10, 2020
@wilkinsona
Copy link
Member

With trace logging enabled, we can see that both configuration files are found and imported:

2020-12-10 10:18:33.611 TRACE 83787 --- [           main] .b.c.c.ConfigDataEnvironmentContributors : Processing imports [optional:file:./config/*/]
2020-12-10 10:18:33.611 TRACE 83787 --- [           main] o.s.b.context.config.ConfigDataLoaders   : Loading file [config/second/application.yaml] using loader org.springframework.boot.context.config.StandardConfigDataLoader
2020-12-10 10:18:33.611 TRACE 83787 --- [           main] o.s.b.context.config.ConfigDataLoaders   : Loading file [config/first/application.yaml] using loader org.springframework.boot.context.config.StandardConfigDataLoader
2020-12-10 10:18:33.611 TRACE 83787 --- [           main] .b.c.c.ConfigDataEnvironmentContributors : Imported 2 resource s[file [config/second/application.yaml], file [config/first/application.yaml]]```

They're then applied to the environment:

2020-12-10 10:18:33.620 TRACE 83787 --- [           main] o.s.b.c.config.ConfigDataEnvironment     : Applying config data environment contributions
2020-12-10 10:18:33.620 TRACE 83787 --- [           main] o.s.b.c.config.ConfigDataEnvironment     : Adding imported property source 'Config resource 'file:./config/*/application.yaml' via location 'optional:file:./config/*/''
2020-12-10 10:18:33.620 TRACE 83787 --- [           main] o.s.b.c.config.ConfigDataEnvironment     : Adding imported property source 'Config resource 'file:./config/*/application.yaml' via location 'optional:file:./config/*/''

The problem is that both property sources have the same name and this results in them being considered equal. This in turns results in the second source that's added replacing the first.

@wilkinsona wilkinsona self-assigned this Dec 10, 2020
@wilkinsona
Copy link
Member

@mbhave @philwebb I've pushed a possible fix but I'd like so more eyes on it before merging please.

@mbhave
Copy link
Contributor

mbhave commented Dec 10, 2020

Looks good to me.

@philwebb philwebb modified the milestones: 2.4.x, 2.4.1 Dec 10, 2020
@philwebb philwebb changed the title Default wildcard config file locations from the working directory do not appear to work as documented Wildcard config file locations from the working directory overrite each other Dec 10, 2020
@philwebb philwebb changed the title Wildcard config file locations from the working directory overrite each other Wildcard config file locations from the working directory override each other Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

5 participants