You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Jochen Eddelbuettel (Jira)" <ji...@apache.org> on 2020/05/17 11:34:00 UTC

[jira] [Commented] (GROOVY-9379) Binding shadows getters in script or base script

    [ https://issues.apache.org/jira/browse/GROOVY-9379?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17109437#comment-17109437 ] 

Jochen Eddelbuettel commented on GROOVY-9379:
---------------------------------------------

Well IntelliJ IDEA just recently caught on to the problem. It did pick up the class set by @BaseScript for a long time already, but now it only accepts explicit get<SomeProp>() calls for type inference and marks <someProp> as dubious. That helps avoiding this trap.

> Binding shadows getters in script or base script
> ------------------------------------------------
>
>                 Key: GROOVY-9379
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9379
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 3.0.0-rc-2
>         Environment: CentOS 8, OpenJDK 11
>            Reporter: Jochen Eddelbuettel
>            Priority: Major
>
>  
> {code:java}
> boolean isPasswordOK() { false }
> binding.setVariable("passwordOK", true)
> if (passwordOK) print "You're in"
> {code}
> 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.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)