Skip to content

Commit 42ba20e

Browse files
yizhenqiangchickenlj
authored andcommitted
Merge pull request #1453, restore the bug that attachment has not been updated in the RpcContext when the Dubbo built-in retry mechanism is triggered.
1 parent 7df5eb6 commit 42ba20e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/AbstractInvoker.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,14 @@ public Result invoke(Invocation inv) throws RpcException {
136136
}
137137
Map<String, String> context = RpcContext.getContext().getAttachments();
138138
if (context != null) {
139-
invocation.addAttachmentsIfAbsent(context);
139+
/**
140+
* invocation.addAttachmentsIfAbsent(context){@link RpcInvocation#addAttachmentsIfAbsent(Map)}should not be used here,
141+
* because the {@link RpcContext#setAttachment(String, String)} is passed in the Filter when the call is triggered
142+
* by the built-in retry mechanism of the Dubbo. The attachment to update RpcContext will no longer work, which is
143+
* a mistake in most cases (for example, through Filter to RpcContext output traceId and spanId and other information).
144+
* yizhenqiang 20180310
145+
*/
146+
invocation.addAttachments(context);
140147
}
141148
if (getUrl().getMethodParameter(invocation.getMethodName(), Constants.ASYNC_KEY, false)) {
142149
invocation.setAttachment(Constants.ASYNC_KEY, Boolean.TRUE.toString());

0 commit comments

Comments
 (0)