qxggg opened a new pull request, #15695:
URL: https://github.com/apache/dubbo/pull/15695

   Fixes #15671
   ## What is the purpose of the change?
   to fix:
   When I set threadPool with my custom threadPool,
   it may be executor reject exception when submit processTask in DefaultFuture.
   The map of Futures cache may can not be clear for long time.
   see #15671
   
   ## MySolution
   Wrap the executor.execute call in a try-catch.
   If the thread pool is full, notifyTimeout is called manually after a 
RejectedExecutionException to clean up and prevent memory leaks.
   ```java
   @Override
   public void run(Timeout timeout) {
       DefaultFuture future = DefaultFuture.getFuture(requestID);
       if (future == null || future.isDone()) {
           return;
       }
       ExecutorService executor = future.getExecutor();
       if (executor != null && !executor.isShutdown()) {
           try {
               executor.execute(() -> notifyTimeout(future));
           } catch (RejectedExecutionException e) {
               notifyTimeout(future);
           }
       } else {
           notifyTimeout(future);
       }
   }
   ```
   ## Checklist
   - [x] Make sure there is a 
[GitHub_issue](https://github.com/apache/dubbo/issues) field for the change.
   - [x] Write a pull request description that is detailed enough to understand 
what the pull request does, how, and why.
   - [x] Write necessary unit-test to verify your logic correction. If the new 
feature or significant change is committed, please remember to add sample in 
[dubbo samples](https://github.com/apache/dubbo-samples) project.
   - [x] Make sure gitHub actions can pass. [Why the workflow is failing and 
how to fix it?](../CONTRIBUTING.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to