alibaba / alibaba/Sentinel

Reactor项目中使用Sentinel偶尔会出现Context0#put空指针异常

Open
#1,907 4 comments 0 reactions 0 assignees View on GitHub
area/integrations help wanted
Dominant language
Java
Stars
23.1k
Forks
8.1k
PR merge metrics
No merged PRs in 30d

Description

WebFlux项目中导入sentinel-spring-webflux-adapter:1.8.0适配模块,项目每天都有好几个NPE,报错内容如下:
```
Caused by: java.lang.NullPointerException: value
at java.util.Objects.requireNonNull(Objects.java:228)
at reactor.util.context.Context0.put(Context0.java:30)
at com.alibaba.csp.sentinel.adapter.reactor.SentinelReactorSubscriber.currentContext(SentinelReactorSubscriber.java:70)
```
对应的源码应该是这一行
```java
return actual.currentContext()
.put(SentinelReactorConstants.SENTINEL_CONTEXT_KEY, currentEntry.getAsyncContext());
```
从异常栈信息看,应该是`currentEntry.getAsyncContext()`这句返回了null,但不知为何会出现null

Contributor guide

Open the contributing guide

Research direction

Start with com.alibaba.csp.sentinel.adapter.reactor.SentinelReactorSubscriber.currentContext and the reported Context0.put stack trace, then trace how currentEntry and its async context are created before this method runs. Reproduce the intermittent failure with the reported WebFlux and sentinel-spring-webflux-adapter:1.8.0 setup; done means the null source is explained and the Context0.put failure is prevented, with a regression check if the project has one.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.