-
Notifications
You must be signed in to change notification settings - Fork 38.5k
CompositePropertySource doesn't fulfil EnumerablePropertySource [SPR-12788] #17385
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
Comments
Juergen Hoeller commented Good point, but I wonder what we can do about this... A Juergen |
Konrad Garus commented If you change the contract on If that was the official specification, it would pretty much mean: "Use at your own risk, but in the end you'll have to call
|
Juergen Hoeller commented I like that idea: an We can easily make this change for 4.2. However, for 4.1.x, it's probably better to preserve the existing behavior, avoiding any disruption at this late maintenance stage of the branch. Juergen |
…aceholderConfigurer Commit 3295289 fixed a number issues with placeholder resolution in PropertySourcesPlaceholderConfigurer. However, in doing so, it replaced a raw PropertySource with a CompositePropertySource which implements EnumerablePropertySource. Consequently, all property sources registered in the Environment must now implement EnumerablePropertySource (which is not an actual requirement). Otherwise, invocations of getPropertyNames() on the CompositePropertySource result in an IllegalStateException, and that is a breaking change which resulted in numerous build failures within the Spring portfolio. To address that regression, this commit introduces a private ConfigurableEnvironmentPropertySource in PropertySourcesPlaceholderConfigurer which is a "raw" PropertySource that delegates directly to the PropertySources in a ConfigurableEnvironment. This commit also extracts the raw PropertySource for direct Environment delegation into a new FallbackEnvironmentPropertySource. See gh-17385 Closes gh-34861
Konrad Garus opened SPR-12788 and commented
In #16897
CompositePropertySource
becameEnumerablePropertySource
. It doesn't fully satisfy its contract though and it violates Liskov substitution principle.For example, Spring Boot assumes that
EnumerablePropertySource.getPropertyNames
contains names of all properties available on the property source. That is not the case withCompositePropertySource
containing non-enumerable property sources. See also spring-projects/spring-boot#2608Affects: 4.1.5
Issue Links:
Referenced from: commits 7e8ffc7
The text was updated successfully, but these errors were encountered: