-
Notifications
You must be signed in to change notification settings - Fork 41.6k
Not planned
Labels
status: supersededAn issue that has been superseded by anotherAn issue that has been superseded by anothertype: enhancementA general enhancementA general enhancement
Description
Line 33 in aaad772
| class ConfigurationPropertySourcesPropertySource extends PropertySource<Iterable<ConfigurationPropertySource>> |
In Springboot application,ConfigurationPropertySourcesPropertySource is added to the environment and as first element, the ConfigurationPropertySourcesPropertySource acts as a facade over the existing property sources.
When handling @Value annotation, org.springframework.core.env.PropertySourcesPropertyResolver#getProperty will be called.
If the property is found then ConfigurationPropertySourcesPropertySource will return the result. otherwise, PropertySourcesPropertyResolver continues to check all subsequent sources. This is a little inefficient for any source that has already been check via ConfigurationPropertySourcesPropertySource.
Metadata
Metadata
Assignees
Labels
status: supersededAn issue that has been superseded by anotherAn issue that has been superseded by anothertype: enhancementA general enhancementA general enhancement
Activity
philwebb commentedon Nov 16, 2021
I think we may have fixed this already with #17400 (commit 6ad100e) which was added to Spring Boot 2.5. @ShijunDeng Can you check that you're using Spring Boot 2.5 or above? If you're finding an issue with that version could you please please provide a sample that shows the problem.
ShijunDeng commentedon Nov 16, 2021
New similar problem with
ConfigurationPropertySourcesPropertyResolverin #17400. My Spring Boot version is 2.5.6.ConfigurationPropertySourcesPropertyResolveris Spring boot source code, but org.springframework.core.env.PropertySourcesPropertyResolver#getProperty is defined in spring-core. The@Valueprocessor use PropertySourcesPropertyResolver. Set a breakpoint in method org.springframework.core.env.PropertySourcesPropertyResolver#getProperty, it's easy to see thatPropertySourcesPropertyResolvercontinues to check all subsequent sources when not found key inConfigurationPropertySourcesPropertySource.as the screenshort below:

PropertySourcesPropertyResolvercontinues to check subsequent source such asSimpleCommandLinePropertySource {name='commandLineArgs'}ShijunDeng commentedon Dec 7, 2021
@philwebb ,hi,How is it going ?
philwebb commentedon Dec 9, 2021
I need to dig a bit more, but I suspect this resolver is being used which doesn't support the short-circuiting.
[-]Short circuit checking of source already covered by ConfigurationPropertySourcesPropertySource[/-][+]Short circuit @Value injection when using a source already covered by ConfigurationPropertySourcesPropertySource[/+]PropertySourcesPlaceholderConfigurerto customizePropertyResolverspring-framework#30304Use configuration resolver to replace standard resolver
Use configuration resolver to replace standard resolver
Use configuration resolver to replace standard resolver
Use configuration resolver to replace standard resolver
Use configuration resolver to replace standard resolver
philwebb commentedon Jun 20, 2023
Closing in favor of PR #34900. Thanks @terminux!