NPE when update Gateway Flow Rule before the api has been requested once #1724
Labels
area/gateway-flow-control
Issues or PRs related to API gateway flow control
good first issue
Good for newcomers
kind/bug
Category issues or prs related to bug.
Milestone
Issue Description
Type: bug report
Describe what happened (or what feature you want)
When my program update the rule whith :
GatewayRuleManager.loadRules(new HashSet<>(FLOW_RULES.values()));
if there has one or more Api has not been requested ,
then there the api resource has not related metric.
that will throws a NPE:
Because there has not metric for this resource , but the method:
com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayRuleManager.GatewayRulePropertyListener private void applyToConvertedParamMap(@NotNull Set<ParamFlowRule> paramFlowRules)
try to clear that with :
ParameterMetricStorage.getParamMetricForResource(resource).clearForRule(rule);
in
com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayRuleManager.GatewayRulePropertyListener
(233 line in
com/alibaba/csp/sentinel/adapter/gateway/common/rule/GatewayRuleManager.java
)Describe what you expected to happen
How to reproduce it (as minimally and precisely as possible)
Tell us your environment
Sentinel Version : 1.8
Anything else we need to know?
The text was updated successfully, but these errors were encountered: