From f08f6cfb42df33070b2a261f20771c509a00ffe0 Mon Sep 17 00:00:00 2001 From: Michael Bazos Date: Thu, 22 May 2025 22:52:39 -0400 Subject: [PATCH] Fixing PropertySourcesPlaceholderConfigurer.java to set the conversion service from the Environment I noticed an issue with PropertySourcesPlaceholderConfigurer moving from spring framework 6.2.6 to 6.2.7. Basically there is a new propertyResolver being created but it is not setting the environments configured conversion service. In the context of spring boot this could cause some issues if custom converters are registered as the propertyResolver if it doesn't have a conversion service set then uses the default and would not include any registered custom converters with the environment. I don't think this PR is the exact correct fix and I didn't add any tests but this did resolve the issue with the propertyResolver having the environments conversion service. If you look at PropertySourcesPlaceholderConfigurer in spring 6.2.6 you will see that the environments conversion service is set on the propertyResolver. Signed-off-by: Michael Bazos --- .../context/support/PropertySourcesPlaceholderConfigurer.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java b/spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java index 4ee1eb73acd0..47e2e831a708 100644 --- a/spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java +++ b/spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java @@ -172,6 +172,10 @@ protected ConfigurablePropertyResolver createPropertyResolver(MutablePropertySou protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, ConfigurablePropertyResolver propertyResolver) throws BeansException { + if(this.environment instanceof ApplicationServletEnvironment) { + propertyResolver.setConversionService(((ApplicationServletEnvironment) this.environment).getConversionService()); + } + propertyResolver.setPlaceholderPrefix(this.placeholderPrefix); propertyResolver.setPlaceholderSuffix(this.placeholderSuffix); propertyResolver.setValueSeparator(this.valueSeparator);