Skip to content

[BUG] SentinelGatewayFilter 限流失效,未能阻断流程 #3571

@15911056747

Description

@15911056747

问题:
在springcloudgateway项目中 使用了内置的SentinelGatewayFilter 做限流控制;在reactor-core版本有3.3.10 升级到3.4.34 版本后,限流失效,未能中断流程依然外调了。
原因:
reactor-core 3.3.10版本MonoIgnoreThen.ThenIgnoreMain 的 subscribeNext()方法中先判断了isCancelled()而reactor-core 3.4.34版本MonoIgnoreThen.ThenIgnoreMain 的 subscribeNext()方法中先判断了publisher 是否是Callable类型是Callable类型才会看isCancelled()状态 非Callable的直接向下订阅了
具体流程:
1.在SentinelGatewayFilter订阅了限流 SentinelReactorSubscriber
2.在内置NettyWriteResponseFilter 通过chain.filter(exchange).then(Mono.defer(()-{}))触发SentinelReactorSubscriber
3.在MonoIgnoreThen 中通过actual.onSubscribe()触发执行
4.在内置SentinelReactorSubscriber 中触发限流 设置cancel状态 执行onError()
5.异常执行完成后,在MonoIgnoreThen.ThenIgnoreMain 的 subscribeNext() 中 由于ignoreMono不是Callable类型继续向下订阅了走了后边的filter

Metadata

Metadata

Assignees

Labels

kind/bugCategory issues or prs related to bug.

Type

No type

Projects

Status

In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions