You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2021/03/02 21:51:00 UTC
[jira] [Updated] (GROOVY-4610) GroovyInterceptable (AOP) not
working with closures
[ https://issues.apache.org/jira/browse/GROOVY-4610?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles updated GROOVY-4610:
--------------------------------
Description:
I've got a grails app with service classes that implement {{GroovyInterceptable}}:
{code:groovy}
class customerSerrvice implements GroovyInterceptable {
private List<Customer> customers
def invokeMethod(String name, args) {
log.debug "=======>INVOKING method [$name] with args:$args"
}
void foo() {
customers.each { doSomething(it) }
}
void doSomething(Customer cust) {
log.debug "doSomething invoked with $cust"
}
}
{code}
If I call foo() or doSomething() *directly* from another class, the invokeMethod gets called like it is supposed to. However, when foo() calls doSomething(), that call is not intercepted in invokeMethod.
If I change from
{code:groovy}
customers.each { doSomething(it) }
{code}
to
{code:groovy}
for(Customer cust: customers) { doSomething(cust) }
{code}
then the invokeMethod gets called just fine.
There appears to be an ExpandoMetaClass bug that prevents closures and GroovyInterceptable from working together.
was:
I've got a grails app with Service classes that inherit from Groovy's GroovyInterceptable:
[code]
class customerSerrvice implements GroovyInterceptable {
private List<Customer> customers
def invokeMethod(String name, args) {
log.debug "=======>INVOKING method [$name] with args:$args"
}
void foo() {
customers.each { doSomething(it) }
}
void doSomething(Customer cust) { log.debug "doSomething invoked with $cust" }
}
[/code]
If I call foo() or doSomething() **directly** from another class, the invokeMethod gets called like it is supposed to. However, when foo() calls doSomething(), that call is not intercepted in invokeMethod.
If I change from
`customers.each { doSomething(it) }`
to
`for(Customer cust: customers) { doSomething(cust) }`
then the invokeMethod gets called just fine.
There appears to be an ExpandoMetaClass bug that prevents closures and GroovyInterceptable from working together.
> GroovyInterceptable (AOP) not working with closures
> ---------------------------------------------------
>
> Key: GROOVY-4610
> URL: https://issues.apache.org/jira/browse/GROOVY-4610
> Project: Groovy
> Issue Type: Bug
> Components: groovy-runtime
> Environment: JDK 1.6.x, Grails 1.2.1
> Reporter: Sunny Thandassery
> Priority: Major
>
> I've got a grails app with service classes that implement {{GroovyInterceptable}}:
> {code:groovy}
> class customerSerrvice implements GroovyInterceptable {
> private List<Customer> customers
> def invokeMethod(String name, args) {
> log.debug "=======>INVOKING method [$name] with args:$args"
> }
> void foo() {
> customers.each { doSomething(it) }
> }
> void doSomething(Customer cust) {
> log.debug "doSomething invoked with $cust"
> }
> }
> {code}
> If I call foo() or doSomething() *directly* from another class, the invokeMethod gets called like it is supposed to. However, when foo() calls doSomething(), that call is not intercepted in invokeMethod.
> If I change from
> {code:groovy}
> customers.each { doSomething(it) }
> {code}
> to
> {code:groovy}
> for(Customer cust: customers) { doSomething(cust) }
> {code}
> then the invokeMethod gets called just fine.
> There appears to be an ExpandoMetaClass bug that prevents closures and GroovyInterceptable from working together.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)