AlbumenJ commented on code in PR #10798:
URL: https://github.com/apache/dubbo/pull/10798#discussion_r1005149841
##########
dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/filter/support/ConsumerContextFilter.java:
##########
@@ -116,8 +114,9 @@ public Result invoke(Invoker<?> invoker, Invocation
invocation) throws RpcExcept
@Override
public void onResponse(Result appResponse, Invoker<?> invoker, Invocation
invocation) {
// pass attachments to result
-
RpcContext.getServerContext().setObjectAttachments(appResponse.getObjectAttachments());
-
+ Map<String, Object> map = appResponse.getObjectAttachments();
+ RpcContext.getClientResponseContext().setObjectAttachments(map);
+ RpcContext.getServerContext().setObjectAttachments(map);
Review Comment:
should not call this method here
##########
dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcContext.java:
##########
@@ -56,7 +56,27 @@ public class RpcContext {
/**
* use internal thread local to improve performance
*/
- private static final InternalThreadLocal<RpcContextAttachment>
SERVER_LOCAL = new InternalThreadLocal<RpcContextAttachment>() {
+ private static final RpcContext AGENT_SERVER_CONTEXT = new
RpcContextAttachment() {
+ @Override
+ public RpcContextAttachment setObjectAttachment(String key, Object
value) {
+ if (value == null) {
+ attachments.remove(key);
+ } else {
+ RpcContext.getServerResponseContext().setAttachment(key,
value);
+ attachments.put(key, value);
+ }
+ return this;
+ }
+ };
Review Comment:
override all methods in RpcContextAttachment, and proxy to serverResponse /
clientResponse
##########
dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcContext.java:
##########
@@ -56,7 +56,27 @@ public class RpcContext {
/**
* use internal thread local to improve performance
*/
- private static final InternalThreadLocal<RpcContextAttachment>
SERVER_LOCAL = new InternalThreadLocal<RpcContextAttachment>() {
+ private static final RpcContext AGENT_SERVER_CONTEXT = new
RpcContextAttachment() {
+ @Override
+ public RpcContextAttachment setObjectAttachment(String key, Object
value) {
+ if (value == null) {
+ attachments.remove(key);
+ } else {
+ RpcContext.getServerResponseContext().setAttachment(key,
value);
+ attachments.put(key, value);
+ }
+ return this;
+ }
Review Comment:
create a new class file for this
##########
dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/RpcContext.java:
##########
@@ -47,9 +47,19 @@ public static RpcContext getContext() {
public static RpcContext getServerContext() {
return new
RpcContext(org.apache.dubbo.rpc.RpcContext.getServerContext());
}
+ public static RpcContext getClientResponseContext() {
+ return new
RpcContext(org.apache.dubbo.rpc.RpcContext.getClientResponseContext());
+ }
+
+ public static RpcContext getServerResponseContext() {
+ return new
RpcContext(org.apache.dubbo.rpc.RpcContext.getServerResponseContext());
+ }
+ public static void removeClientResponseContext() {
+ org.apache.dubbo.rpc.RpcContext.removeClientResponseContext();
+ }
- public static void removeServerContext() {
- org.apache.dubbo.rpc.RpcContext.removeServerContext();
Review Comment:
recover this API
##########
dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/PenetrateAttachmentSelector.java:
##########
@@ -29,6 +29,7 @@ public interface PenetrateAttachmentSelector {
*
* @return attachment pass to next hop
*/
- Map<String, Object> select();
+ Map<String, Object> select(Invocation invocation);
+ Map<String, Object> selectReverse(Invocation invocation);
Review Comment:
Add `RpcContextAttachment serverAttachement / clientResponse` param
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]