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 Theodorou (Jira)" <ji...@apache.org> on 2020/01/29 17:09: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=17026042#comment-17026042 ]
Jochen Theodorou commented on GROOVY-9379:
------------------------------------------
I agree with what you wrote, the only problem is that this is not really a bug. It is per design, but from a time prior to Groovy 1, when Groovy had for example no real property-missing mechanism and basically no idea support. Changing this now would be a major breaking change. But using a script base class can actually bypass this, if the base class overwrite get/setProperty.. or the script for that matter.
> 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)