javamelody / grails-melody-plugin

JavaMelody monitoring plugin for Grails, to monitor application performance
https://plugins.grails.org/plugin/grails-melody-plugin
Apache License 2.0
32 stars 31 forks source link

fix interception when method is a closure #31

Closed agastald closed 7 years ago

agastald commented 8 years ago

When the method of a service is a closure the args must be transformed for proper handling of the closure.

The problem can be reproduced as follows:

class X { def myClosure = { "${it?.class?.simpleName}:$it" } }
class Y { def myClosure = { "${it?.class?.simpleName}:$it" } }

X.metaClass.invokeMethod = { String name, args ->
    property = delegate."${name}"
    // actual implementation
    property.call(args)
    // solution
//    property.call(args ? args.size() == 1 ? args[0] : args as List : null)
}

assert new X().myClosure('a') == new Y().myClosure('a')
PerGon commented 8 years ago

I'm having the exact same problem. This PR fixes it.

Any feedback? Will it be merged?

evernat commented 8 years ago

This PR is probably good. But there is another PR #33, which changes the same file. I think that PR #33 should be merged first, after reviewing it. Maybe you can help reviewing and testing PR #33 which comes from https://github.com/sergiomichels/grails-melody-plugin

evernat commented 8 years ago

@agastald PR #33 is merged now. Can you change this PR or submit a new PR based on the new files? Thanks.

bassmartin commented 8 years ago

See https://github.com/javamelody/grails-melody-plugin/pull/37 that uses the latest files.

sergiomichels commented 7 years ago

37 Merged.