alibaba / alibaba/Sentinel

Add support for asynchronous Servlet in Sentinel Web Servlet Filter

Open
#306 7 comments 0 reactions 0 assignees View on GitHub
help wanted kind/enhancement
Dominant language
Java
Stars
23.1k
Forks
8.1k
PR merge metrics
No merged PRs in 30d

Description

## Issue Description

Type: *feature request*

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

Support asynchronous Servlet in Sentinel Web Servlet Filter.

Spring Boot中使用 `CompletableFuture` or `DefferdResult` or `Callable` 作为返回值,引入 Sentinel CommonFilter 后无法响应,且无法正确统计。是否支持两种形式(同步与异步 Servlet)并存,比如使用案例如下:

```java
@RestController
public class AsyncController {

@GetMapping("/async")
public CompletableFuture async() {

return CompletableFuture.supplyAsync(() -> {

try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
return "async\";
}
);

}

}
```

Contributor guide

Open the contributing guide

Research direction

Start at the Sentinel Web Servlet Filter entry point and compare its handling of synchronous requests with the asynchronous Spring Boot controller example using CompletableFuture, DeferredResult, or Callable. Done means asynchronous Servlet requests respond successfully and are counted correctly while synchronous and asynchronous forms can coexist.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.