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

Abierto
#3,488 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
java
Área
api, backend

Línea de trabajo

Comience con SentinelReactorSubscriber.entryWhenSubscribed() y reproduzca el fallo en sentinel-webflux-example utilizando el SlotChainBuilder personalizado mostrado en el issue. Compruebe cómo se propaga RuntimeException a través de Spring WebFlux y DefaultErrorWebExceptionHandler. Se considera completado cuando la solicitud del cliente termina con la excepción gestionada, en lugar de permanecer bloqueada, y el fallo puede observarse mediante el registro o la propagación del error.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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的所有异常,问题解决

Lenguaje dominante
Java
Estrellas
23.1k
Forks
8.1k
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de alibaba/Sentinel

Todos los issues de alibaba/Sentinel

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.