You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "jacob shnaidman (JIRA)" <ji...@apache.org> on 2017/12/01 21:23:00 UTC
[jira] [Created] (GROOVY-8398) Overriding getProperty makes
getAttribute throw missing property exception
jacob shnaidman created GROOVY-8398:
---------------------------------------
Summary: Overriding getProperty makes getAttribute throw missing property exception
Key: GROOVY-8398
URL: https://issues.apache.org/jira/browse/GROOVY-8398
Project: Groovy
Issue Type: Bug
Affects Versions: 2.4.12
Environment: Ubuntu
Reporter: jacob shnaidman
The following code fails in two unexpected ways:
{code:java}
class PropClass {
String myString = 'groovyClass'
String otherProp = 'other Property'
void myMethod() {
//do nothing
}
void registerMethod(Closure closure) {
this.metaClass.myMethod = closure
}
def getProperty(String name) {
if (name == 'otherProp')
//forward the request to getter
return metaClass.getProperty(this, name)
else if (name == 'myString') {
return 'myString'
}
else
return "new var $name"
}
}
PropClass properties = new PropClass()
GroovyAssert.shouldFail {
println properties.metaClass.getAttribute(properties, 'myString')
}
properties.registerMethod { ->
println 'this fails'
}
{code}
This happens whenever you override getProperties
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)