[BUG] webflux中SlotChainBuilder实例化异常后客户端被无限阻塞

Đang mở
#3,488 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
java
Lĩnh vực
api, backend

Hướng nghiên cứu

Bắt đầu với SentinelReactorSubscriber.entryWhenSubscribed() và tái hiện lỗi trong sentinel-webflux-example bằng SlotChainBuilder tùy chỉnh được nêu trong issue. Kiểm tra cách RuntimeException đi qua Spring WebFlux và DefaultErrorWebExceptionHandler. Được xem là hoàn tất khi yêu cầu của client kết thúc với exception được xử lý thay vì tiếp tục bị chặn, và có thể quan sát lỗi thông qua logging hoặc lan truyền lỗi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Issue Description

Type: bug report

Describe what happened

在spring-webflux中使用sentinel
请求过程中实例化SlotChainBuilder报错后DefaultErrorWebExceptionHandler无法正常处理异常并且不会输出任何日志,客户端请求被无限阻塞.
原因是SentinelReactorSubscriber的entryWhenSubscribed()方法只处理了BlockException异常

private void entryWhenSubscribed() {
        ContextConfig sentinelContextConfig = this.entryConfig.getContextConfig();
        if (sentinelContextConfig != null) {
            ContextUtil.enter(sentinelContextConfig.getContextName(), sentinelContextConfig.getOrigin());
        }

        try {
            AsyncEntry entry = SphU.asyncEntry(this.entryConfig.getResourceName(), this.entryConfig.getResourceType(), this.entryConfig.getEntryType(), this.entryConfig.getAcquireCount(), this.entryConfig.getArgs());
            this.currentEntry = entry;
            this.actual.onSubscribe(this);
        } catch (BlockException ex) {
            this.entryExited.set(true);
            this.cancel();
            this.actual.onSubscribe(this);
            this.actual.onError(ex);
        } finally {
            if (sentinelContextConfig != null) {
                ContextUtil.exit();
            }

        }

    }
Describe what you expected to happen
How to reproduce it (as minimally and precisely as possible)
  1. 使用sentinel示例项目sentinel-webflux-example
  2. 配置com.alibaba.csp.sentinel.slotchain.SlotChainBuilder的自定义实现
public class TestBuilder extends DefaultSlotChainBuilder {

    @Override
    public ProcessorSlotChain build() {
        ProcessorSlotChain chain = super.build();
        if(1==1){
            // 强制抛出异常
            throw new RuntimeException();
        }
        return chain;
    }
}
Tell us your environment

jdk21、spring-webflux:3.2.9

Anything else we need to know?

entryWhenSubscribed()方法中处理包括BlockException的所有异常,问题解决

Ngôn ngữ chính
Java
Star
23.1k
Fork
8.1k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của alibaba/Sentinel

Tất cả issue của alibaba/Sentinel

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.