Skip to content

Commit

Permalink
Fix callback timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
wuwen5 committed Jan 11, 2022
1 parent 2fc9e27 commit 987fd70
Showing 1 changed file with 5 additions and 1 deletion.
Expand Up @@ -28,6 +28,7 @@
import org.apache.dubbo.rpc.AsyncRpcResult;
import org.apache.dubbo.rpc.Invocation;
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 All @@ -36,6 +37,7 @@
import java.net.InetSocketAddress;
import java.util.concurrent.CompletableFuture;

import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_TIMEOUT;
import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.PATH_KEY;
import static org.apache.dubbo.remoting.Constants.SENT_KEY;
Expand Down Expand Up @@ -71,7 +73,9 @@ protected Result doInvoke(Invocation invocation) throws Throwable {
currentClient.send(inv, getUrl().getMethodParameter(invocation.getMethodName(), SENT_KEY, false));
return AsyncRpcResult.newDefaultAsyncResult(invocation);
} else {
CompletableFuture<AppResponse> appResponseFuture = currentClient.request(inv).thenApply(obj -> (AppResponse) obj);
final String methodName = RpcUtils.getMethodName(invocation);
final int timeout = (int) RpcUtils.getTimeout(getUrl(), methodName, RpcContext.getContext(), DEFAULT_TIMEOUT);
CompletableFuture<AppResponse> appResponseFuture = currentClient.request(inv, timeout, null).thenApply(obj -> (AppResponse) obj);
return new AsyncRpcResult(appResponseFuture, inv);
}
} catch (RpcException e) {
Expand Down

0 comments on commit 987fd70

Please sign in to comment.