Skip to content

Commit

Permalink
fix(alibaba#10427): When the execution of handleServerRequest() encou…
Browse files Browse the repository at this point in the history
…nters an exception, record the log and throw an exception, then quickly response to the server errResponse (alibaba#10770)
  • Loading branch information
Bo-Qiu authored Jul 13, 2023
1 parent 8fa83ce commit 156cd62
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,7 @@ protected Response handleServerRequest(final Request request) {
} catch (Exception e) {
LoggerUtils.printIfInfoEnabled(LOGGER, "[{}] HandleServerRequest:{}, errorMessage = {}",
rpcClientConfig.name(), serverRequestHandler.getClass().getName(), e.getMessage());
throw e;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,4 +635,19 @@ public ServerInfo nextRpcServer() {
}
};
}

@Test(expected = RuntimeException.class)
public void testHandleServerRequestWhenExceptionThenThrowException() throws RuntimeException {
RpcClient rpcClient = buildTestNextRpcServerClient();
Request request = new Request() {
@Override
public String getModule() {
return null;
}
};
rpcClient.serverRequestHandlers.add(req -> {
throw new RuntimeException();
});
rpcClient.handleServerRequest(request);
}
}

0 comments on commit 156cd62

Please sign in to comment.