You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Andy Wilkinson (Jira)" <ji...@apache.org> on 2020/07/23 09:24:00 UTC

[jira] [Created] (GROOVY-9650) MissingPropertyException when accessing @Log-generated log field from a CGLib-proxied outer class

Andy Wilkinson created GROOVY-9650:
--------------------------------------

             Summary: MissingPropertyException when accessing @Log-generated log field from a CGLib-proxied outer class
                 Key: GROOVY-9650
                 URL: https://issues.apache.org/jira/browse/GROOVY-9650
             Project: Groovy
          Issue Type: Bug
    Affects Versions: 2.5.13
            Reporter: Andy Wilkinson


There appears to be a regression in Groovy 2.5.13. It can be reproduced with the following script:

{code}
import groovy.util.logging.Log
import java.lang.reflect.Method
import java.util.function.Consumer
import net.sf.cglib.proxy.MethodInterceptor
import net.sf.cglib.proxy.MethodProxy
import net.sf.cglib.proxy.Enhancer

@Log
@Grab("cglib:cglib:3.3.0")
class Thing {

	void method() {
		Runnable nested = {
			log.info("hello")
		}
		nested.run()
	}

}

def enhancer = new Enhancer()
enhancer.superclass = Thing
enhancer.callback = { obj, method, args, proxy -> 
    proxy.invokeSuper(obj, args);
} as MethodInterceptor

def proxy = enhancer.create()
proxy.method()
{code}

When run with Groovy 2.5.12, {{hello}} is logged:

{noformat}
$ sdk use groovy 2.5.12

Using groovy version 2.5.12 in this shell.
$ groovy logging.groovy
Jul 23, 2020 10:20:05 AM java_util_logging_Logger$info$0 call
INFO: hello
{noformat}

With Groovy 2.5.13, the {{log}} field cannot be found:

{noformat}
$ sdk use groovy 2.5.13

Using groovy version 2.5.13 in this shell.
$ groovy logging.groovy
Caught: groovy.lang.MissingPropertyException: No such property: log for class: Thing$$EnhancerByCGLIB$$ac2265fe
groovy.lang.MissingPropertyException: No such property: log for class: Thing$$EnhancerByCGLIB$$ac2265fe
	at net.sf.cglib.proxy.MethodProxy$invokeSuper.call(Unknown Source)
	at logging$_run_closure1.doCall(logging.groovy:24)
	at com.sun.proxy.$Proxy16.intercept(Unknown Source)
	at Thing$$EnhancerByCGLIB$$ac2265fe.getProperty(<generated>)
	at Thing$_method_closure1.doCall(logging.groovy:14)
	at Thing$_method_closure1.doCall(logging.groovy)
	at Thing.method(logging.groovy:16)
	at Thing$$EnhancerByCGLIB$$ac2265fe.CGLIB$method$0(<generated>)
	at Thing$$EnhancerByCGLIB$$ac2265fe$$FastClassByCGLIB$$704960d8.invoke(<generated>)
	at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
	at net.sf.cglib.proxy.MethodProxy$invokeSuper.call(Unknown Source)
	at logging$_run_closure1.doCall(logging.groovy:24)
	at com.sun.proxy.$Proxy16.intercept(Unknown Source)
	at Thing$$EnhancerByCGLIB$$ac2265fe.method(<generated>)
	at Thing$$EnhancerByCGLIB$$ac2265fe$method.call(Unknown Source)
	at logging.run(logging.groovy:28)
{noformat}

The problem does not occur if {{Thing}} is not proxied or when trying to access a field that explicit declared rather than being created via {{@Log}}.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)