-
Notifications
You must be signed in to change notification settings - Fork 26.5k
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
[Dubbo-619] Fix #619 and PR #2956 is not enough #3634
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3634 +/- ##
============================================
+ Coverage 63.44% 63.51% +0.06%
Complexity 71 71
============================================
Files 703 706 +3
Lines 31000 32096 +1096
Branches 5024 5311 +287
============================================
+ Hits 19669 20386 +717
- Misses 9066 9370 +304
- Partials 2265 2340 +75
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise, looks good to me.
dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcResult.java
Outdated
Show resolved
Hide resolved
@carryxyh 谢谢你的建议. 大家在看这个 PR 前建议先看下 PR #2956 , 那里分析了出现issue #619 的原因. PR #2956 那样改在社区版里看上去是没有问题的, 但是在某些情况下会有问题: 比如我们公司在FailoverClusterInvoker.doInvoke()里加了全链路监控埋点的代码, 如下所示: 在finally块里, 我们会取详细的exception异常栈(如果有的话), 然后记录在链路日志中, 用的如下这段: 在执行这段代码之前, result.getException()里的stackTrace是null, 这没有问题, 因为服务端本来就抛出了没有异常栈的NullPointerException, (如果这里不懂的话, 建议先看一下 #2956 , 那里有详细的分析). stackTrace 就变成了错误的异常栈, 也就是 issue #619 中出现那个误导用户的异常栈, 之所以在PR #2956 后还是有这个问题, 是因为是先执行的上面那块代码, 然后再执行RpcResult.recreate(), 而PR #2956 是在recreate里做的修改, 其实应该是在DecodeableRpcResult 类的handleException()方法里做异常栈的判断和修改: 本 PR 的目的是优化 PR #2956 , 在decode时就实现异常栈的检测和修改, 而不是等到InvokerInvocationHandler.invoke()后, recreate()时再做检测, 否则如果用户做二次开发时, 在诸如FailoverClusterInvoker.doInvoke()里用类似ExceptionUtils.getStackTrace()方法就破坏了异常栈, 所以要在源头就做好检测和修改, 这样更好一点. |
@carryxyh hi, could you tell me why merging is blocked, thank you. |
What is the purpose of the change
Fix #619 , and PR #2956 is not enough in the following use case:
In souche.com, we add 'trace' function in dubbo, such as in FailoverClusterInvoker.doInvoke, we get stackTrace from exception to log detail exception info using the following:
org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace(result.getException())
The above sentence will result the same problem with issue #619 .
So, we should solve this in decode stage.
#619 这个问题, PR #2956 貌似已经解决了, 但是我们公司(souche.com)在对dubbo加全链路埋点时, 还是遇到了之前的问题, 因为 #2956 是在InvokerInvocationHandler.invoke()方法的invoker.invoke(invocation)后解决了问题, 但是我们在FailoverClusterInvoker.doInvoke()方法里坐全链路埋点时, 为了能取到异常栈的信息, 用了如下的语句:
org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace(result.getException())
导致了异常栈又出问题了..
所以应该在decode后, 对exception对象做判断才对.
Brief changelog
RpcResult.java
RpcResultTest.java
Follow this checklist to help us incorporate your contribution quickly and easily:
[Dubbo-XXX] Fix UnknownException when host config not exist #XXX
. Each commit in the pull request should have a meaningful subject line and body.mvn clean install -DskipTests=false
&mvn clean test-compile failsafe:integration-test
to make sure unit-test and integration-test pass.