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

Script.getProperty vs Script.setProperty asymmetry

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.6
    • 4.0.0-beta-1
    • GroovyScriptEngine
    • None

    Description

      @groovy.transform.Field i = 5
      
      assert getProperty("i") == 5 // ok
      assert i == 5 // ok
      
      setProperty("i", getProperty("i") + 1)
      
      assert getProperty("i") == 6 // ok
      assert i == 6 // fails, i is currently 5
      

      Effectively

      • script.getProperty did read script.i field
      • while script.setProperty stored value only to Binding, not to script.i field

      Please consider script.setProperty to detect that there is script.$name field, and if there is, write there and only there to match getProperty behavior.

      Attachments

        Activity

          People

            emilles Eric Milles
            neopaf Alexander Petrossian (PAF)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: