Skip to content

Commit ac0387f

Browse files
committed
Apply common conversion service to PropertySourcesConfig. Fixes #10158
1 parent c8ddc84 commit ac0387f

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

grails-core/src/main/groovy/grails/boot/config/GrailsApplicationPostProcessor.groovy

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import org.springframework.context.event.ApplicationContextEvent
3434
import org.springframework.context.event.ContextClosedEvent
3535
import org.springframework.context.event.ContextRefreshedEvent
3636
import org.springframework.core.convert.converter.Converter
37+
import org.springframework.core.convert.support.ConfigurableConversionService
3738
import org.springframework.core.env.AbstractEnvironment
3839
import org.springframework.core.env.ConfigurableEnvironment
3940
import org.springframework.core.env.EnumerablePropertySource
@@ -109,16 +110,17 @@ class GrailsApplicationPostProcessor implements BeanDefinitionRegistryPostProces
109110

110111
protected void loadApplicationConfig() {
111112
org.springframework.core.env.Environment environment = applicationContext.getEnvironment()
113+
ConfigurableConversionService conversionService = null
112114
if(environment instanceof ConfigurableEnvironment) {
113115
if(environment instanceof AbstractEnvironment) {
114-
def cs = environment.getConversionService()
115-
cs.addConverter(new Converter<NavigableMap.NullSafeNavigator, String>() {
116+
conversionService = environment.getConversionService()
117+
conversionService.addConverter(new Converter<NavigableMap.NullSafeNavigator, String>() {
116118
@Override
117119
public String convert(NavigableMap.NullSafeNavigator source) {
118120
return null;
119121
}
120122
});
121-
cs.addConverter(new Converter<NavigableMap.NullSafeNavigator, Object>() {
123+
conversionService.addConverter(new Converter<NavigableMap.NullSafeNavigator, Object>() {
122124
@Override
123125
public Object convert(NavigableMap.NullSafeNavigator source) {
124126
return null;
@@ -138,7 +140,11 @@ class GrailsApplicationPostProcessor implements BeanDefinitionRegistryPostProces
138140
}
139141
}
140142
}
141-
((DefaultGrailsApplication)grailsApplication).config = new PropertySourcesConfig(propertySources)
143+
def config = new PropertySourcesConfig(propertySources)
144+
if(conversionService != null) {
145+
config.setConversionService( conversionService )
146+
}
147+
((DefaultGrailsApplication)grailsApplication).config = config
142148
}
143149
}
144150

0 commit comments

Comments
 (0)