fix the consumer remoteApplication is null (#12635)
* fix the consumer remoteApplication is null * fix the consumer remoteApplication is null * fix the consumer remoteApplication is null * fix the consumer remoteApplication is null
This commit is contained in:
parent
70a948a3d4
commit
94e7244eb0
|
|
@ -379,7 +379,7 @@ public abstract class AbstractClusterInvoker<T> implements ClusterInvoker<T> {
|
|||
if (ProfilerSwitch.isEnableSimpleProfiler()) {
|
||||
InvocationProfilerUtils.enterProfiler(invocation, "Invoker invoke. Target Address: " + invoker.getUrl().getAddress());
|
||||
}
|
||||
invocation.addInvokedInvoker(invoker);
|
||||
setRemote(invoker, invocation);
|
||||
result = invoker.invoke(invocation);
|
||||
} finally {
|
||||
clearContext(originInvoker);
|
||||
|
|
@ -388,6 +388,17 @@ public abstract class AbstractClusterInvoker<T> implements ClusterInvoker<T> {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the remoteAddress and remoteApplicationName so that filter can get them.
|
||||
*
|
||||
*/
|
||||
private void setRemote(Invoker<?> invoker, Invocation invocation) {
|
||||
invocation.addInvokedInvoker(invoker);
|
||||
RpcServiceContext serviceContext = RpcContext.getServiceContext();
|
||||
serviceContext.setRemoteAddress(invoker.getUrl().toInetSocketAddress());
|
||||
serviceContext.setRemoteApplicationName(invoker.getUrl().getRemoteApplication());
|
||||
}
|
||||
|
||||
/**
|
||||
* When using a thread pool to fork a child thread, ThreadLocal cannot be passed.
|
||||
* In this scenario, please use the invokeWithContextAsync method.
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ import org.apache.dubbo.rpc.Invocation;
|
|||
import org.apache.dubbo.rpc.InvokeMode;
|
||||
import org.apache.dubbo.rpc.Invoker;
|
||||
import org.apache.dubbo.rpc.Result;
|
||||
import org.apache.dubbo.rpc.RpcContext;
|
||||
import org.apache.dubbo.rpc.RpcException;
|
||||
import org.apache.dubbo.rpc.RpcInvocation;
|
||||
import org.apache.dubbo.rpc.protocol.AbstractInvoker;
|
||||
|
|
@ -111,8 +110,6 @@ public class DubboInvoker<T> extends AbstractInvoker<T> {
|
|||
|
||||
invocation.setAttachment(TIMEOUT_KEY, String.valueOf(timeout));
|
||||
|
||||
RpcContext.getServiceContext().setRemoteAddress(currentClient.getRemoteAddress());
|
||||
|
||||
Integer payload = getUrl().getParameter(PAYLOAD, Integer.class);
|
||||
|
||||
Request request = new Request();
|
||||
|
|
|
|||
Loading…
Reference in New Issue