Skip to content

Commit ba42766

Browse files
author
yzhfd
committed
修复http timeout后重复response的bug
1 parent d18e56e commit ba42766

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

trpc-proto/trpc-proto-http/src/main/java/com/tencent/trpc/proto/http/server/AbstractHttpExecutor.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public abstract class AbstractHttpExecutor {
5858

5959
private static final Logger logger = LoggerFactory.getLogger(AbstractHttpExecutor.class);
6060

61+
private volatile boolean isTimeout = false;
62+
6163
/**
6264
* Http codec tool
6365
*/
@@ -82,6 +84,7 @@ protected void execute(HttpServletRequest request, HttpServletResponse response,
8284
requestTimeout = methodInfoAndInvoker.getInvoker().getConfig().getRequestTimeout();
8385
}
8486
if (requestTimeout > 0 && !countDownLatch.await(requestTimeout, TimeUnit.MILLISECONDS)) {
87+
isTimeout = true;
8588
throw TRpcException.newFrameException(ErrorCode.TRPC_SERVER_TIMEOUT_ERR,
8689
"wait http request execute timeout");
8790
} else {
@@ -128,6 +131,10 @@ private void invokeRpcRequest(ProviderInvoker<?> invoker, DefRequest rpcRequest,
128131
CompletionStage<Response> future = invoker.invoke(rpcRequest);
129132
future.whenComplete((result, t) -> {
130133
try {
134+
if (isTimeout) {
135+
return;
136+
}
137+
131138
// Throw the call exception, which will be handled uniformly by the exception handling program.
132139
if (t != null) {
133140
throw t;

0 commit comments

Comments
 (0)