This is an automated email from the ASF dual-hosted git repository. wujimin pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git
commit c3e0a57c5b67069d661636c4b9f045041dc2afd5 Author: liubao <bi...@qq.com> AuthorDate: Thu Nov 26 21:16:15 2020 +0800 [SCB-2131]when timeout exception, connect closed will trigger asynchronous callback --- .../transport/rest/client/http/RestClientInvocation.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/transports/transport-rest/transport-rest-client/src/main/java/org/apache/servicecomb/transport/rest/client/http/RestClientInvocation.java b/transports/transport-rest/transport-rest-client/src/main/java/org/apache/servicecomb/transport/rest/client/http/RestClientInvocation.java index 838131d..18f6f58 100644 --- a/transports/transport-rest/transport-rest-client/src/main/java/org/apache/servicecomb/transport/rest/client/http/RestClientInvocation.java +++ b/transports/transport-rest/transport-rest-client/src/main/java/org/apache/servicecomb/transport/rest/client/http/RestClientInvocation.java @@ -84,6 +84,8 @@ public class RestClientInvocation { private Handler<Throwable> throwableHandler = e -> fail((ConnectionBase) clientRequest.connection(), e); + private boolean alreadyFailed = false; + public RestClientInvocation(HttpClientWithContext httpClientWithContext, List<HttpClientFilter> httpClientFilters) { this.httpClientWithContext = httpClientWithContext; this.httpClientFilters = httpClientFilters; @@ -115,8 +117,10 @@ public class RestClientInvocation { } clientRequest.exceptionHandler(e -> { - invocation.getTraceIdLogger().error(LOGGER, "Failed to send request, local:{}, remote:{}, message={}.", - getLocalAddress(), ipPort.getSocketAddress(), ExceptionUtils.getExceptionMessageWithoutTrace(e)); + invocation.getTraceIdLogger() + .error(LOGGER, "Failed to send request, alreadyFailed:{}, local:{}, remote:{}, message={}.", + alreadyFailed, getLocalAddress(), ipPort.getSocketAddress(), + ExceptionUtils.getExceptionMessageWithoutTrace(e)); throwableHandler.handle(e); }); @@ -129,7 +133,9 @@ public class RestClientInvocation { restClientRequest.end(); } catch (Throwable e) { invocation.getTraceIdLogger().error(LOGGER, - "send http request failed, local:{}, remote: {}, message={}.", getLocalAddress(), ipPort + "send http request failed, alreadyFailed:{}, local:{}, remote: {}, message={}.", + alreadyFailed, + getLocalAddress(), ipPort , ExceptionUtils.getExceptionMessageWithoutTrace(e)); fail((ConnectionBase) clientRequest.connection(), e); } @@ -249,10 +255,12 @@ public class RestClientInvocation { } protected void fail(ConnectionBase connection, Throwable e) { - if (invocation.isFinished()) { + if (alreadyFailed) { return; } + alreadyFailed = true; + InvocationStageTrace stageTrace = invocation.getInvocationStageTrace(); // connection maybe null when exception happens such as ssl handshake failure if (connection != null) {