-
Notifications
You must be signed in to change notification settings - Fork 26.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
使用@SPI的wrapper方式报空指针异常bug #7176
Comments
@zhihuayu hi, would you pls provide more detailed information for The situation you use wrapper and the stack trace for NPE are both needed. |
非常感谢您的回复,也非常抱歉没有提供详细的堆栈信息。经调试,主要是因为duboo在初始化构建调用链时,即调用ProtocolFilterWrapper.buildInvokerChain方法时:
其原因在ExtensionLoader的getActivateExtension方法中:
实际上,抛出的空指针异常是在ActivateComparator.COMPARATOR比较排序的时候抛出的,如下所示ActivateComparator.parseActivate方法中,由于没有考虑Activate是否存在的情况,所以会抛出控制在异常:
|
应该不是这个问题吧?getActivateExtension 方法遍历的是 cachedActivates.entrySet(),而 cachedActivates 缓存的是被 Activate 注解修饰的类,所以在排序的时候,应该全部是包含 Activate 注解的类.
|
对的,但是Activate 注解修饰的类可以被没有Activate注解的wrapper类所修饰,原理是在调用getExtension(name)方法时会进行包装,包装之后再排序,所以会有空指针异常。 |
@zhihuayu thanks for your explanation I have tried to reroduce this situation, and I found that the main reason which causes NPE in In order to slove this problem, maybe we can make We can fix it in the next release. |
@AlbumenJ 非常感谢您的回复 |
@zhihuayu @xiaoheng1 非常欢迎提个 pr 到主干仓库 |
already in process. |
@xiaoheng1 已经提交了,谢谢! |
不好意思,我没在这个 issue 中看到相关的 pull request 链接那 |
@chickenlj 刚才已经提交pull request。 |
Related pr #7234 |
… see apache#7176. (cherry picked from commit df6d6ad)
…pache#7326) * fix Use @SPI's wrapper method to report a null pointer exception bug. see apache#7176. (cherry picked from commit df6d6ad) * fix apache#7176 Use @SPI's wrapper method to report a null pointer exception bug * recover wildcard import * delete issue link * add new spi interface. * fix testActivateComparator test case. Co-authored-by: xiaoheng <xiaoyu> (cherry picked from commit a10d7f3)
Environment
比如,有如下的wrapper方式的Filter,在服务启动的时候会报空指针异常。
经查是因为active的排序导致,如果改成如下方式,则不会报错,但是其排序可能会无效,所以希望官方能做一个完整的方案,谢谢!
The text was updated successfully, but these errors were encountered: