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

Binding shadows getters in script or base script

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 3.0.0-rc-2
    • Fix Version/s: None
    • Component/s: groovy-runtime
    • Labels:
      None
    • Environment:
      CentOS 8, OpenJDK 11

      Description

       

      boolean isPasswordOK() { false }
      binding.setVariable("passwordOK", true)
      if (passwordOK) print "You're in"
      

      Accessing a variable available in the binding takes precedent over utilizing a getter. This is extremely risky if the script author doesn't have full control over the binding and forgets to call all his getters explicitly, especially when they come from a BaseScript and he/she uses the code suggestions from IntelliJ, which show any getters as simple property names.

      The expected behaviour of the code above, should be NOT to let anyone in.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              eddelplus Jochen Eddelbuettel
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: