lishunli / nutz

Automatically exported from code.google.com/p/nutz
0 stars 0 forks source link

Nut.Aop 当方法的返回值为基本数据类型,而拦截器的beforeInvoke返回false时,会出现NPE #148

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
问题产生的条件:
方法的返回值为基本数据类型,且拦截器的beforeInvoke返回false

发生问题的调用代码:
public class SecurityMethod {
    @Aop(value={"check"}) 
    public int giveMeMoney(){
        return Integer.MAX_VALUE;
    }
}

//ioc容器中的名字为"check"
public class Check extends AbstractMethodInterceptor {

public boolean beforeInvoke(Object obj, Method method, Object... args) {
    return false;
}
}
异常堆栈:
Exception in thread "main" java.lang.NullPointerException
    at org.nutz.aop.demo.target.SecurityMethod$$NUTZAOP.giveMeMoney(Unknown
Source)
    at org.nutz.aop.demo.DemoA.main(DemoA.java:32)

相关日志:

Original issue reported on code.google.com by wendal1985@gmail.com on 27 Mar 2010 at 5:26

GoogleCodeExporter commented 9 years ago
fix in r986

Original comment by wendal1985@gmail.com on 27 Mar 2010 at 5:27

GoogleCodeExporter commented 9 years ago

Original comment by wendal1985@gmail.com on 27 Mar 2010 at 5:28

GoogleCodeExporter commented 9 years ago
字节码没有处理 WrapperClass 吧,呵呵 ^_^

Original comment by zozoh...@gmail.com on 29 Mar 2010 at 2:23

GoogleCodeExporter commented 9 years ago
错, 处理了.只是没有考虑到一个情况:
Integer it = null;
it.intValue();
这样会爆NPE

Original comment by wendal1985@gmail.com on 29 Mar 2010 at 2:38

GoogleCodeExporter commented 9 years ago
被拦截的是原生类型返回值,也会得到 null ?

Original comment by zozoh...@gmail.com on 29 Mar 2010 at 2:51

GoogleCodeExporter commented 9 years ago

Original comment by wendal1985@gmail.com on 13 May 2010 at 11:09

GoogleCodeExporter commented 9 years ago
Verified in 1.a.28

Original comment by wendal1985@gmail.com on 15 May 2010 at 8:29