Groovy
  1. Groovy
  2. GROOVY-6304 Configslurper Issues
  3. GROOVY-4493

ConfigSlurper().parse() - property not located correctly in returned tree.

    Details

    • Type: Sub-task Sub-task
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.7.5, 1.8-beta-2
    • Fix Version/s: None
    • Component/s: groovy-jdk
    • Labels:
      None
    • Environment:
      windows 7; java version "1.6.0_21; gdk I.7.5 but also occurs for gdk 1.8.0 beta 2.

      Description

      package tasktrack;
      
      import groovy.util.GroovyTestCase;
      class ConfigSurlperTest extends GroovyTestCase {
      
      	public void testParseScript() {
      		def configFile = '''
      		log4j {
      			rootLogger="debug,stdout"
      			appender {		
      				stdout("org.apache.log4j.ConsoleAppender") { // See Note 2
      					layout("org.apache.log4j.PatternLayout") {		  
      						ConversionPattern="%5p [%t] (%F:%L) - %m%n"
      					}
      				}
      			}		
      		}
      		'''
      		
      		def cfg = new ConfigSlurper().parse(configFile)
      		assertEquals "debug,stdout", cfg.log4j.rootLogger  //Pass
      		assertEquals "org.apache.log4j.ConsoleAppender", cfg.log4j.appender.stdout //Pass
      		assertEquals "org.apache.log4j.PatternLayout", cfg.log4j.appender.stdout.layout // Fails - See Note 1
      	}
      }
      

      Note 1
      ======

      Result in the following exception

      groovy.lang.MissingPropertyException: No such property: layout for class: java.lang.String
      at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:49)
      at org.codehaus.groovy.runtime.callsite.GetEffectivePojoPropertySite.getProperty(GetEffectivePojoPropertySite.java:63)
      ...

      Note 2
      ======

      The third assert works when the value, org.apache.log4j.ConsoleAppender, is not declared.
      That is:

      ...
      appender {
      stdout {
      layout("org.apache.log4j.PatternLayout")

      { ConversionPattern="%5p [%t] (%F:%L) - %m%n" }

      }
      }
      ...

        Activity

        Tom Weekes created issue -
        Roshan Dawrani made changes -
        Field Original Value New Value
        Description package tasktrack;

        import groovy.util.GroovyTestCase;
        class ConfigSurlperTest extends GroovyTestCase {

        public void testParseScript() {
        def configFile = '''
        log4j {
        rootLogger="debug,stdout"
        appender {
        stdout("org.apache.log4j.ConsoleAppender") { // See Note 2
        layout("org.apache.log4j.PatternLayout") {
        ConversionPattern="%5p [%t] (%F:%L) - %m%n"
        }
        }
        }
        }
        '''

        def cfg = new ConfigSlurper().parse(configFile)
        assertEquals "debug,stdout", cfg.log4j.rootLogger //Pass
        assertEquals "org.apache.log4j.ConsoleAppender", cfg.log4j.appender.stdout //Pass
        assertEquals "org.apache.log4j.PatternLayout", cfg.log4j.appender.stdout.layout // Fails - See Note 1
        }
        }


        Note 1
        ======

        Result in the following exception

        groovy.lang.MissingPropertyException: No such property: layout for class: java.lang.String
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:49)
        at org.codehaus.groovy.runtime.callsite.GetEffectivePojoPropertySite.getProperty(GetEffectivePojoPropertySite.java:63)
        ...

        Note 2
        ======

        The third assert works when the value, org.apache.log4j.ConsoleAppender, is not declared.
        That is:

        ...
        appender {
        stdout {
        layout("org.apache.log4j.PatternLayout") {
        ConversionPattern="%5p [%t] (%F:%L) - %m%n"
        }
        }
        }
        ...
        {code}
        package tasktrack;

        import groovy.util.GroovyTestCase;
        class ConfigSurlperTest extends GroovyTestCase {

        public void testParseScript() {
        def configFile = '''
        log4j {
        rootLogger="debug,stdout"
        appender {
        stdout("org.apache.log4j.ConsoleAppender") { // See Note 2
        layout("org.apache.log4j.PatternLayout") {
        ConversionPattern="%5p [%t] (%F:%L) - %m%n"
        }
        }
        }
        }
        '''

        def cfg = new ConfigSlurper().parse(configFile)
        assertEquals "debug,stdout", cfg.log4j.rootLogger //Pass
        assertEquals "org.apache.log4j.ConsoleAppender", cfg.log4j.appender.stdout //Pass
        assertEquals "org.apache.log4j.PatternLayout", cfg.log4j.appender.stdout.layout // Fails - See Note 1
        }
        }
        {code}

        Note 1
        ======

        Result in the following exception

        groovy.lang.MissingPropertyException: No such property: layout for class: java.lang.String
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:49)
        at org.codehaus.groovy.runtime.callsite.GetEffectivePojoPropertySite.getProperty(GetEffectivePojoPropertySite.java:63)
        ...

        Note 2
        ======

        The third assert works when the value, org.apache.log4j.ConsoleAppender, is not declared.
        That is:

        ...
        appender {
        stdout {
        layout("org.apache.log4j.PatternLayout") {
        ConversionPattern="%5p [%t] (%F:%L) - %m%n"
        }
        }
        }
        ...
        Pascal Schumacher made changes -
        Issue Type Bug [ 1 ] Sub-task [ 7 ]
        Parent GROOVY-6304 [ 148075 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Mark Thomas made changes -
        Workflow jira [ 12733429 ] Default workflow, editable Closed status [ 12745191 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12973682 ] Default workflow, editable Closed status [ 12980828 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Tom Weekes
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Development