Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-2195

ConfigSlurper does not resolve within closures references to outer properties

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.1-beta-3
    • 1.1-rc-2
    • groovy-jdk
    • None
    • Windows XP sp2
      Java 1.6.0_02-b06

    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

      Attachments

        1. ConfigSlurper.patch
          0.6 kB
          Gabriele Garuglieri

        Activity

          People

            blackdrag Jochen Theodorou
            garu Gabriele Garuglieri
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: