You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
问题一: 子方法抛出异常无法被上级调用者afterThrowing感知
问题二:子方法抛出的异常, 被子方法自身的的afterThrowing 感知
重现步骤:
对 final int checkState(int a) 方法在afterReturning的时候抛出异常,并关注该方法afterThrowing事件
同时也关注final void checkState()的afterThrowing事件
期望结果:final void checkState() 可以响应 afterThrowing 事件
实际结果:final int checkState(int a) 方法响应afterThrowing事件了,final void checkState()未响应afterThrowing事件
问题一: 子方法抛出异常无法被上级调用者afterThrowing感知
问题二:子方法抛出的异常, 被子方法自身的的afterThrowing 感知
重现步骤:
对 final int checkState(int a) 方法在afterReturning的时候抛出异常,并关注该方法afterThrowing事件
同时也关注final void checkState()的afterThrowing事件
期望结果:final void checkState() 可以响应 afterThrowing 事件
实际结果:final int checkState(int a) 方法响应afterThrowing事件了,final void checkState()未响应afterThrowing事件
分析:
1.根据字节码增强规则,Spy.onReturn 相关代码处在Sandbox的try-catch 逻辑中,因此onReturn主动抛出的异常会被try-catch 捕获,触发当前方法的Spy.onThrows规则
2.由于Spy.onReturn和Spy.onThrows,都会触发EventListenerHandler.handleOnEnd ,导致
3.使用了AdviceAdapterListener,在处理RETURN和IMMEDIATELY_RETURN 事件过程中,也会导致OpStack opStack 多次出栈,造成OpStack栈的错位
解决方案:
第一种方案: 同级调用中的Spy.onThrows 忽略 同级的Spy.onReturn中通过ProcessControlException 的THROWS_IMMEDIATELY事件抛出的异常,同时注意对齐栈的操作
第二种方案:ProcessControlException 的THROWS_IMMEDIATELY事件触发后,补齐EventProcessor.Process 和OpStack的栈
The text was updated successfully, but these errors were encountered: