diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/DefaultFuture.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/DefaultFuture.java index f18edb088141..08ca7cfb66c6 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/DefaultFuture.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/DefaultFuture.java @@ -328,7 +328,7 @@ public void run(Timeout timeout) { try { executor.execute(() -> notifyTimeout(future)); } catch (RejectedExecutionException e) { - notifyTimeout(future); + notifyExecutionError(future, e); throw e; } } else { @@ -345,5 +345,17 @@ private void notifyTimeout(DefaultFuture future) { // handle response. DefaultFuture.received(future.getChannel(), timeoutResponse, true); } + + private void notifyExecutionError(DefaultFuture future, Throwable e) { + // create exception response. + Response errorResponse = new Response(future.getId()); + // set error status + errorResponse.setStatus(Response.SERVER_THREADPOOL_EXHAUSTED_ERROR); + // set detailed error message + errorResponse.setErrorMessage("Executor rejected the task for handling timeout notification: " + + e.getClass().getSimpleName() + " - " + e.getMessage()); + // handle response. + DefaultFuture.received(future.getChannel(), errorResponse, true); + } } }