AlbumenJ commented on issue #10188:
URL: https://github.com/apache/dubbo/issues/10188#issuecomment-1171172340
> > > > 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() 方法是感知不到的
> >
> >
> > 这里应该在 catch 异常的时候将线程的 isInterrupted 状态置上去,如果目前 Dubbo 没有做的话也需要完善下
>
> 看了下源代码是没有做个操作的,所以写了这个pr #10164 , 我觉得核心是用户主动打断产生的异常, 不应该被重试(即使设置了重试次数)
#10164 的问题是 InterruptedException.class
这个异常可能是服务端抛出来的异常(即是业务异常),不一定是客户端的异常。所以直接判断 cause 为 InterruptedException 是有问题的。
--
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]