[
https://issues.apache.org/jira/browse/GROOVY-7771?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15172965#comment-15172965
]
Jochen Theodorou commented on GROOVY-7771:
------------------------------------------
I think you misunderstand... The default for a Script is that the variable must
be assigned to at least before it becomes available for a read. But by
exchanging the Binding to one, that does something else, like creating the
variable on first read and if there was no write yet, we get a different
behaviour. If we start checking hasVariable, this won't work anymore. This
would still work of course, but you get in trouble with getVariables, plus in
that case you never have the exception problem.
> Exception driven control flow in groovy.lang.Script.getProperty()
> -----------------------------------------------------------------
>
> Key: GROOVY-7771
> URL: https://issues.apache.org/jira/browse/GROOVY-7771
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 2.4.6
> Reporter: Benjamin Graf
> Assignee: Pascal Schumacher
>
> groovy.lang.Script.getProperty() calls Binding.getProperty() and does
> therfore react on MissingPropertyException. This control flow is an
> antipattern causing unnecessary Throwable.fillInStackTrace() calls which cost
> cpu time. It might be better to check with Binding.hasProperty() first to
> avoid Exception flow.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)