You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2022/12/16 03:22:56 UTC
[GitHub] [dubbo] AlbumenJ commented on a diff in pull request #11144: fix #11033
AlbumenJ commented on code in PR #11144:
URL: https://github.com/apache/dubbo/pull/11144#discussion_r1050335917
##########
dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ContextFilter.java:
##########
@@ -125,7 +126,11 @@ public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcExcept
}
if (invocation instanceof RpcInvocation) {
- ((RpcInvocation) invocation).setInvoker(invoker);
+ RpcInvocation rpcInvocation = (RpcInvocation) invocation;
+ rpcInvocation.setInvoker(invoker);
+ //write all attachments back;
+ rpcInvocation.getObjectAttachments().putAll(context.getObjectAttachments());
+
Review Comment:
It would be better to fill in the attachment when creating rpcInvocation, so as to avoid the performance loss caused by multiple coverage. If it is to pass information from the rest filter, you can extend a field in RpcServiceContext, obtain it in AbstractProxyInvoker and use it when creating a new invocation.
##########
dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/proxy/AbstractProxyInvoker.java:
##########
@@ -97,6 +99,11 @@ public Result invoke(Invocation invocation) throws RpcException {
}
}
+ Map<String, String> invocationAttachments = invocation.getAttachments();
+ if (CollectionUtils.isNotEmptyMap(invocationAttachments)) {
+ RpcContext.getClientAttachment().getObjectAttachments().putAll(invocationAttachments);
+ }
+
Review Comment:
It would be better to replace the way to get attachment in customized filter of rest protocol to `org.apache.dubbo.rpc.RpcServiceContext#getInvocation` to get the origin invocation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org