alibaba / alibaba/Sentinel

ahas集成到zuul1.x网关限流后没有抛出ZuulException,导致无法进入Zuul的异常处理过滤器SendErrorFilter

Open
#1,870 1 comment 0 reactions 0 assignees View on GitHub
area/gateway-flow-control area/integrations kind/question
Dominant language
Java
Stars
23.1k
Forks
8.1k
PR merge metrics
No merged PRs in 30d

Description

## Issue Description

Type: *bug report*

### Describe what happened (or what feature you want)

ahas与zuul1.x集成实现网关限流。如果被限流,抛出BlockException之后,没有抛出ZuulException,因而无法进入Zuul的错误处理流程。
代码在:com.alibaba.csp.sentinel.adapter.gateway.zuul.filters.SentinelZuulPreFilter#run
95-103行
```java
} catch (BlockException var12) {
ZuulBlockFallbackProvider zuulBlockFallbackProvider = ZuulBlockFallbackManager.getFallbackProvider(fallBackRoute);
BlockResponse blockResponse = zuulBlockFallbackProvider.fallbackResponse(fallBackRoute, var12);
ctx.setRouteHost((URL)null);
ctx.set("serviceId", (Object)null);
ctx.setResponseBody(blockResponse.toString());
ctx.setResponseStatusCode(blockResponse.getCode());
ctx.getResponse().setContentType("application/json; charset=utf-8");
}

```

### Describe what you expected to happen
限流完成后抛出一个Zuul异常
```java
catch (BlockException e) {
ZuulBlockFallbackProvider zuulBlockFallbackProvider = ZuulBlockFallbackManager.getFallbackProvider(fallBackRoute);
BlockResponse blockResponse = zuulBlockFallbackProvider.fallbackResponse(fallBackRoute, var12);
ctx.setRouteHost((URL)null);
ctx.set("serviceId", (Object)null);
ctx.setResponseBody(blockResponse.toString());
ctx.setResponseStatusCode(blockResponse.getCode());
ctx.getResponse().setContentType("application/json; charset=utf-8");
throw new ZuulException(e,"sentinel流控",429,"SentinelZuulPreFilter");

```

### How to reproduce it (as minimally and precisely as possible)

1. 接入ahas(我接入的公网试用版本)
2. 在ahas网关防护中添加流控规则
3. 触发流控

### Tell us your environment
spring-cloud-zuul-starter-ahas-sentinel 1.2.2
spring-cloud-starter-netflix-zuul 2.2.6.RELEASE

### Anything else we need to know?

Contributor guide

Open the contributing guide

Research direction

Start in SentinelZuulPreFilter#run around lines 95-103 and reproduce the rate-limiting flow with spring-cloud-zuul-starter-ahas-sentinel 1.2.2 and spring-cloud-starter-netflix-zuul 2.2.6.RELEASE. Confirm that a blocked request raises ZuulException and reaches Zuul's SendErrorFilter error handling path.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.