Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-6304 Configslurper Issues
  3. GROOVY-5047

ConfigSlurper confuses nested property names with top-level property names

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.7.6, 1.8.2, 1.9-beta-3
    • None
    • groovy-jdk
    • None

    Description

      When ConfigSlurper processes a property nested inside a Closure AND that same property exists as a top-level property name, the value is added to the top level property instead of the nested one. Simple test case to demonstrate:

      def config = """
      report.table = "XXX"
      study

      { report.name = "ABC" }
      """

      def config2 = """
      study { report.name = "ABC" }

      """

      def slurper = new ConfigSlurper().parse(config)
      println slurper
      assert slurper.study.report.name == [:] // BUG!
      assert slurper.report.name == "ABC" // BUG!

      def slurper2 = new ConfigSlurper().parse(config2)
      println slurper2
      assert slurper2.study.report.name == "ABC"

      The first slurper incorrectly sets report.name instead of study.report.name, while the second slurper behaves as expected. The only difference is the extra property "report.table" defined in the first config.

      This seems to be related to bugs: https://jira.codehaus.org/browse/GROOVY-2986, https://jira.codehaus.org/browse/GROOVY-3334, and https://jira.codehaus.org/browse/GROOVY-3521

      Attachments

        1. slurperBug.groovy
          0.4 kB
          Curtis Caravone

        Activity

          People

            Unassigned Unassigned
            caravone Curtis Caravone
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: