Short circuit @Value injection when using a source already covered by ConfigurationPropertySourcesPropertySource #34900
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.
Hi, I found that
PropertySourcesPropertyResolver
(a resolver that does not support short-circuiting) is used in these places:LoggingSystemProperties
spring-boot/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystemProperties.java
Line 165 in 08ce091
spring-boot/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ErrorProperties.java
Line 35 in 5817c84
In this case
ConfigurationPropertyName.of(key, true)
will return null, and thendefaultResolver
(inherited fromPropertySourcesPropertyResolver
) will be used for resolution.spring-boot/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertySourcesPropertyResolver.java
Lines 87 to 97 in 5817c84
However the entire process property value will only be retrieved once, the current implementation is fine and we don't need to make any changes.
spring-boot/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertySourcesPropertySource.java
Lines 66 to 68 in 5817c84
PropertySourcesPlaceholderConfigurer
, may need to wait AllowPropertySourcesPlaceholderConfigurer
to customizePropertyResolver
spring-framework#30304 to fixspring-boot/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/context/PropertyPlaceholderAutoConfiguration.java
Line 43 in 5817c84
Closes gh-28687