Skip to content

Commit d3052eb

Browse files
committed
Handle nulls in getProperty(..) of CodeGenConfig. Fixes #9798
1 parent 4b61ce3 commit d3052eb

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

grails-bootstrap/src/main/groovy/org/grails/config/CodeGenConfig.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class CodeGenConfig implements Cloneable, ConfigMap {
161161
}
162162

163163
protected <T> T convertToType(Object value, Class<T> requiredType) {
164-
if(value instanceof NavigableMap.NullSafeNavigator) {
164+
if(value == null || value instanceof NavigableMap.NullSafeNavigator) {
165165
return null
166166
}
167167
else if(requiredType.isInstance(value)) {

grails-bootstrap/src/test/groovy/grails/config/GrailsConfigSpec.groovy

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,16 @@ class GrailsConfigSpec extends Specification{
1616
config.configMap.grails.profile == 'web'
1717
config.configMap.grails.containsKey('somekey') == true
1818
}
19-
19+
20+
def "Should support conversion from null to other objects"() {
21+
given:
22+
CodeGenConfig config = new CodeGenConfig()
23+
config.put('foo.bar', null)
24+
25+
expect:
26+
config.getProperty("foo.bar", Map.class) == null
27+
28+
}
2029
def "should support merging maps"() {
2130
given:
2231
CodeGenConfig config = new CodeGenConfig()

0 commit comments

Comments
 (0)