Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-4610

GroovyInterceptable (AOP) not working with closures

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.0.0-beta-1, 3.0.9
    • groovy-runtime
    • None
    • JDK 1.6.x, Grails 1.2.1

    Description

      I've got a grails app with service classes that implement GroovyInterceptable:

      class customerService 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"
          } 
      } 
      

      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.

      Attachments

        Activity

          People

            emilles Eric Milles
            blusynergy Sunny Thandassery
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: