Skip to content

Commit

Permalink
[ISSUE apache#7833] Fix invokeImpl() in RemotingAbstract
Browse files Browse the repository at this point in the history
  • Loading branch information
guyinyou authored Feb 19, 2024
1 parent 1b46d18 commit 7dc0e5a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -496,13 +496,7 @@ public RemotingCommand invokeSyncImpl(final Channel channel, final RemotingComma

public CompletableFuture<ResponseFuture> invokeImpl(final Channel channel, final RemotingCommand request,
final long timeoutMillis) {
String channelRemoteAddr = RemotingHelper.parseChannelRemoteAddr(channel);
doBeforeRpcHooks(channelRemoteAddr, request);
return invoke0(channel, request, timeoutMillis).whenComplete((v, t) -> {
if (t == null) {
doAfterRpcHooks(channelRemoteAddr, request, v.getResponseCommand());
}
});
return invoke0(channel, request, timeoutMillis);
}

protected CompletableFuture<ResponseFuture> invoke0(final Channel channel, final RemotingCommand request,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,9 @@ public CompletableFuture<RemotingCommand> invoke(String addr, RemotingCommand re
public CompletableFuture<ResponseFuture> invokeImpl(final Channel channel, final RemotingCommand request,
final long timeoutMillis) {
Stopwatch stopwatch = Stopwatch.createStarted();
String channelRemoteAddr = RemotingHelper.parseChannelRemoteAddr(channel);
doBeforeRpcHooks(channelRemoteAddr, request);

return super.invokeImpl(channel, request, timeoutMillis).thenCompose(responseFuture -> {
RemotingCommand response = responseFuture.getResponseCommand();
if (response.getCode() == ResponseCode.GO_AWAY) {
Expand Down Expand Up @@ -839,6 +842,10 @@ public CompletableFuture<ResponseFuture> invokeImpl(final Channel channel, final
}
}
return CompletableFuture.completedFuture(responseFuture);
}).whenComplete((v, t) -> {
if (t == null) {
doAfterRpcHooks(channelRemoteAddr, request, v.getResponseCommand());
}
});
}

Expand Down

0 comments on commit 7dc0e5a

Please sign in to comment.