大目老师您好:
代码已经上传到了码云上(https://gitee.com/morning-feather/springcloudalibabademo.git)。
复现步骤如下:
1.导入数据库脚本stamprally_stamp_center.sql和stamprally_user_center.sql
2.分别启动两个工程(注册到nocas上)
3.访问http://localhost:8011/customer/1后sentinel中出现user-centre
4.在簇点链路中添加资源名为(GET:http://stamp-center/stamp/{id})的流控规则后,流控规则中并没有添加成功该资源名的流控规则
5.分析发现源码中ModifyRulesCommandHandler.class的第66行
List<FlowRule> flowRules = JSONArray.parseArray(data, FlowRule.class);
Json对象(data)转换成数组对象(FlowRule)的时候竟然给我resource这个属性变成了null
data:
[{"clusterConfig":{"fallbackToLocalWhenFail":true,"sampleCount":10,"strategy":0,"thresholdType":0,"windowIntervalMs":1000},"clusterMode":false,"controlBehavior":0,"count":1.0,"grade":1,"limitApp":"default","maxQueueingTimeMs":500,"resource":"GET:http://stamp-center/stamp/{id}","strategy":0,"warmUpPeriodSec":10}]
flowRules:
[FlowRule{resource=null, limitApp=default, grade=1, count=1.0, strategy=0, refResource=null, controlBehavior=0, warmUpPeriodSec=10, maxQueueingTimeMs=500, clusterMode=false, clusterConfig=ClusterFlowConfig{flowId=null, thresholdType=0, fallbackToLocalWhenFail=true, strategy=0, sampleCount=10, windowIntervalMs=1000}, controller=null}]