Skip to content

Commit

Permalink
fix(#13305): RpcContext local address info get null on custom filter (#…
Browse files Browse the repository at this point in the history
…13751)

* fix(#13305): RpcContext local address info get null on custom filter

* fix ci build failed

* fix ci build failed
  • Loading branch information
aofall authored Mar 11, 2024
1 parent d50adb7 commit 36e0cf5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.utils.CollectionUtils;
import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.rpc.AsyncRpcResult;
import org.apache.dubbo.rpc.Filter;
import org.apache.dubbo.rpc.Invocation;
Expand Down Expand Up @@ -63,10 +62,7 @@ public ConsumerContextFilter(ApplicationModel applicationModel) {

@Override
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
RpcContext.getServiceContext()
.setInvoker(invoker)
.setInvocation(invocation)
.setLocalAddress(NetUtils.getLocalHost(), 0);
RpcContext.getServiceContext().setInvoker(invoker).setInvocation(invocation);

RpcContext context = RpcContext.getClientAttachment();
context.setAttachment(REMOTE_APPLICATION_KEY, invoker.getUrl().getApplication());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
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;
Expand Down Expand Up @@ -98,6 +99,7 @@ protected Result doInvoke(final Invocation invocation) throws Throwable {
} else {
currentClient = exchangeClients.get(index.getAndIncrement() % exchangeClients.size());
}
RpcContext.getServiceContext().setLocalAddress(currentClient.getLocalAddress());
try {
boolean isOneway = RpcUtils.isOneway(getUrl(), invocation);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ protected Result doInvoke(final Invocation invocation) {
isSync(methodDescriptor, invocation) ? new ThreadlessExecutor() : streamExecutor;
ClientCall call = new TripleClientCall(
connectionClient, callbackExecutor, getUrl().getOrDefaultFrameworkModel(), writeQueue);
RpcContext.getServiceContext().setLocalAddress(connectionClient.getLocalAddress());
AsyncRpcResult result;
try {
switch (methodDescriptor.getRpcType()) {
Expand Down

0 comments on commit 36e0cf5

Please sign in to comment.