-
Notifications
You must be signed in to change notification settings - Fork 38.2k
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
Allow PropertySourcesPlaceholderConfigurer
subclass to customize PropertyResolver
#26761
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! |
.../src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java
Outdated
Show resolved
Hide resolved
@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! |
hi @rstoyanchev , can you review this ? |
Bump up this, as we are still having issue to overwrite this setting in the newer version of spring. Thanks. |
This commit reintroduces the ability to customize the PropertyResolver to use in PropertySourcesPropertyResolver See gh-26761
@1zg12 thanks very much for making your first contribution to the Spring Framework. |
PropertySourcesPlaceholderConfigurer
to customize PropertyResolver
PropertySourcesPlaceholderConfigurer
to customize PropertyResolver
PropertySourcesPlaceholderConfigurer
subclass to customize PropertyResolver
Background
Prior to Spring 5.2, when we need to customize the PropertiesLoader, we can subclass
PropertyPlaceholderConfigurer
, and override theresolvePlaceholder
method.Now with
PropertySourcesPlaceholderConfigurer
deprecatedPropertyPlaceholderConfigurer
, theresolvePlaceholder
method has been moved out of thePlaceHolderConfigurer
and into a separatePropertyResolver
.Somehow the
PropertyResolver
is 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
resolvePlaceholder
now becomes to duplicate the wholepostProcessBeanFactory
method and then provide customPropertyResolver
.Changes
Instead of hardcoding a
PropertyResolver
as existing and make it very difficult to customize, this PR will point to a factory method to provide thePropertyResolver
as needed.I believe there is no side effect on this. It only adds the flexibility for customization which has been lost.
Note [*]
Even though
PropertyPlaceholderConfigurer
was 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
resolvePlaceholder
of the current class implementationspring-framework/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.java
Line 250 in 01bea34