alibaba / alibaba/Sentinel

持久化热点规则出现的问题:objectMapper不能将规则json转换成ParamFlowRule

Open
#1,710 8 comments 0 reactions 0 assignees View on GitHub
area/dashboard
Dominant language
Java
Stars
23.1k
Forks
8.1k
PR merge metrics
No merged PRs in 30d

Description

## Issue Description

Type: *bug report*

新增一个热点规则时,传来的json数据不能转换成com.alibaba.csp.sentinel.slots.block.flow.param.ParamFlowRule

收到的json(即图中的ruleStr):
```
{"app":"sentinel","gmtModified":1598930162707,"port":8723,"ip":"192.168.0.190","rule":{"burstCount":0,"clusterConfig":{"fallbackToLocalWhenFail":true,"sampleCount":10,"thresholdType":0,"windowIntervalMs":1000},"clusterMode":false,"controlBehavior":0,"count":1.0,"durationInSec":1,"grade":1,"limitApp":"default","maxQueueingTimeMs":0,"paramFlowItemList":[],"paramIdx":0,"resource":"a"},"id":18,"gmtCreate":1598930162707}
```

![image](https://user-images.githubusercontent.com/44300551/91800406-7e197c80-ec5b-11ea-81f1-af842542522f.png)

readValue执行后得到的Object:
![image](https://user-images.githubusercontent.com/44300551/91800519-b02ade80-ec5b-11ea-822c-6df354ffea5f.png)

控制台是模仿源码中的nacos流控规则改造的

publisher:
![image](https://user-images.githubusercontent.com/44300551/91800718-144da280-ec5c-11ea-89e5-5ff712d6016f.png)

controller
![image](https://user-images.githubusercontent.com/44300551/91800836-5545b700-ec5c-11ea-9b58-ad589bea6ad7.png)

个人觉得原因是ParamFlowRule 和 ParamFlowRuleEntity 结构不一致导致的。希望可以得到解决的方法

Contributor guide

Open the contributing guide

Research direction

Start with the publisher and controller entry points shown in the report, then inspect the ObjectMapper readValue call and compare ParamFlowRule with ParamFlowRuleEntity. Use the provided rule JSON to reproduce the conversion failure and trace the Nacos flow-rule implementation for comparison. Done means the hotspot rule JSON converts to the expected ParamFlowRule structure.

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
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.