happytimor commented on issue #10188:
URL: https://github.com/apache/dubbo/issues/10188#issuecomment-1168662311

   > 1. 打断重试的这个需求应该是我们需要支持的,只是实现的方式需要考虑下
   > 2. 是否可以在 catch 异常的时候判断当前线程是否是已经被打断的,以此来确定是否需要把报错外发
   
   写了一个简单的代码模拟下:
   ```java
       public static void main(String[] args) throws InterruptedException {
           ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 
0, TimeUnit.SECONDS, new LinkedBlockingQueue<>());
   
           Future<?> submit = threadPoolExecutor.submit(() -> {
               System.out.println("before: " + 
Thread.currentThread().isInterrupted());
               dubboInvoke();
               System.out.println("end: " + 
Thread.currentThread().isInterrupted());
           });
           Thread.sleep(1000);
           submit.cancel(true);
       }
   
   
       static void dubboInvoke() {
           try {
               interruptError();
           } catch (Exception e) {
               //retry invoke
           }
       }
   
       static void interruptError() throws Exception {
           try {
               Thread.sleep(5000);
               System.out.println("wake up");
           } catch (Exception e) {
               //contains interrupt exception(RpcException)
               throw e;
           }
       }
   ```
   
   控制台输出信息:
   ``` java
   before: false
   end: false
   ```
   
   invoke产生的InterruptException没有被抛出, 外层通过 
Thread.currentThread().isInterrupted() 方法是感知不到的


-- 
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