Allow PropertySourcesPlaceholderConfigurer subclass to customize PropertyResolver#26761
Closed
1zg12 wants to merge 1 commit into
Closed
Allow PropertySourcesPlaceholderConfigurer subclass to customize PropertyResolver#267611zg12 wants to merge 1 commit into
PropertySourcesPlaceholderConfigurer subclass to customize PropertyResolver#267611zg12 wants to merge 1 commit into
Conversation
|
@1wpro2 Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
|
@1wpro2 Thank you for signing the Contributor License Agreement! |
cuspymd
reviewed
Apr 5, 2021
|
@1zg12 Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
|
@1zg12 Thank you for signing the Contributor License Agreement! |
Contributor
Author
|
hi @rstoyanchev , can you review this ? |
Contributor
Author
|
Bump up this, as we are still having issue to overwrite this setting in the newer version of spring. Thanks. |
snicoll
pushed a commit
that referenced
this pull request
Aug 26, 2023
This commit reintroduces the ability to customize the PropertyResolver to use in PropertySourcesPropertyResolver See gh-26761
snicoll
added a commit
that referenced
this pull request
Aug 26, 2023
Member
|
@1zg12 thanks very much for making your first contribution to the Spring Framework. |
PropertySourcesPlaceholderConfigurer to customize PropertyResolver
PropertySourcesPlaceholderConfigurer to customize PropertyResolverPropertySourcesPlaceholderConfigurer subclass to customize PropertyResolver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
Prior to Spring 5.2, when we need to customize the PropertiesLoader, we can subclass
PropertyPlaceholderConfigurer, and override theresolvePlaceholdermethod.Now with
PropertySourcesPlaceholderConfigurerdeprecatedPropertyPlaceholderConfigurer, theresolvePlaceholdermethod has been moved out of thePlaceHolderConfigurerand into a separatePropertyResolver.Somehow the
PropertyResolveris hardcoded [*]:spring-framework/spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java
Line 157 in 01bea34
Due to the hardcode, the only way left for developers to override the
resolvePlaceholdernow becomes to duplicate the wholepostProcessBeanFactorymethod and then provide customPropertyResolver.Changes
Instead of hardcoding a
PropertyResolveras existing and make it very difficult to customize, this PR will point to a factory method to provide thePropertyResolveras needed.I believe there is no side effect on this. It only adds the flexibility for customization which has been lost.
Note [*]
Even though
PropertyPlaceholderConfigurerwas also using a hardcoded class,spring-framework/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.java
Line 210 in 01bea34
It's a private inner class, which even doesn't allow override. However, after several redirects, it eventually points to the
resolvePlaceholderof the current class implementationspring-framework/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.java
Line 250 in 01bea34