Skip to content

Commit 0db6e2b

Browse files
committed
Merge branch '3.1.x' into 3.2.x
2 parents 10803de + 9c5be5e commit 0db6e2b

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
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

grails-core/src/main/groovy/org/grails/spring/context/support/MapBasedSmartPropertyOverrideConfigurer.groovy

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,8 @@ class MapBasedSmartPropertyOverrideConfigurer implements BeanFactoryPostProcesso
6060
final beanPropertyValue = beanPropertiesMap.get(beanPropertyName)
6161
applyPropertyValue(factory, beanName.toString(), beanPropertyName.toString(), beanPropertyValue)
6262
}
63-
6463
}
65-
6664
}
67-
6865
}
6966

7067
protected void applyPropertyValue(ConfigurableListableBeanFactory factory, String beanName, String property, Object value) {
@@ -116,15 +113,14 @@ class MapBasedSmartPropertyOverrideConfigurer implements BeanFactoryPostProcesso
116113
}
117114

118115
protected BeanDefinition getTargetBeanDefinitionForFactoryBean(ConfigurableListableBeanFactory factory,
119-
String beanName, BeanDefinition beanDefinition, Class beanClass) {
116+
String beanName, BeanDefinition beanDefinition, Class<? extends FactoryBean> beanClass) {
120117

121118
if (TransactionProxyFactoryBean.isAssignableFrom(beanClass)) {
122119
getTargetBeanDefinition(factory, beanName,
123120
(BeanDefinition)beanDefinition.propertyValues.getPropertyValue("target").value)
124121
}
125122
else {
126-
throw new BeanCreationException(beanName,
127-
"Unable to determine target bean definition for FactoryBeans of type " + beanClass.name)
123+
beanDefinition
128124
}
129125
}
130126
}

0 commit comments

Comments
 (0)