Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.1-beta-3
-
Fix Version/s: 1.1-rc-2
-
Component/s: groovy-jdk
-
Labels:None
-
Environment:Windows XP sp2
Java 1.6.0_02-b06
-
Number of attachments :
Description
When processing a scoped closure ConfigSlurper does not resolve references to properties defined out of closure scope.
For example this config file:
a0 = "Goofy"
a1 = "$a0"
a2."$a0" = "Mickey Mouse and " + "$a0"
group1 {
a0 = "Donald Duck"
}
group2 {
a0 = "$a0"
a1 = "$group1.a0"
}
a3 = "$group1.a0"
produces the following:
a0=Goofy
a1=Goofy
a2.Goofy=Mickey Mouse and Goofy
group1.a0=Donald Duck
group2.a0=[:]
group2.a1=[:]
a3=Donald Duck
Applying this patch to ConfigSlurper
— C:/export/java/Groovy/groovy-1.1-beta-3/src/main/groovy/util/ConfigSlurper-save.groovy Fri Sep 21 00:40:58 2007
+++ C:/export/java/Groovy/groovy-1.1-beta-3/src/main/groovy/util/ConfigSlurper.groovy Thu Oct 11 10:10:30 2007
@@ -159,8 +159,9 @@
if(current[name]) { result = current[name] - }
- else { + } else if (config[name]) { + result = config[name] + } else { result = new ConfigObject() current[name] = result }
makes it correctly resolving "group2" references:
group2.a0=Goofy
group2.a1=Donald Duck
Sorry, it looks like the cut and paste somehow mangled the patch.
I'm attaching it as a file.