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:
java.lang.NullPointerException: null
at com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayRuleManager$GatewayRulePropertyListener.applyToConvertedParamMap(GatewayRuleManager.java:230) ~[sentinel-api-gateway-adapter-common-1.8.0.jar:na]
at com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayRuleManager$GatewayRulePropertyListener.applyGatewayRuleInternal(GatewayRuleManager.java:200) ~[sentinel-api-gateway-adapter-common-1.8.0.jar:na]
at com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayRuleManager$GatewayRulePropertyListener.configUpdate(GatewayRuleManager.java:118) ~[sentinel-api-gateway-adapter-common-1.8.0.jar:na]
at com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayRuleManager$GatewayRulePropertyListener.configUpdate(GatewayRuleManager.java:114) ~[sentinel-api-gateway-adapter-common-1.8.0.jar:na]
at com.alibaba.csp.sentinel.property.DynamicSentinelProperty.updateValue(DynamicSentinelProperty.java:57) ~[sentinel-core-1.8.0.jar:1.8.0]
at com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayRuleManager.loadRules(GatewayRuleManager.java:78) ~[sentinel-api-gateway-adapter-common-1.8.0.jar:na]
at ****.java:50) ~[classes/:na]
at ****.java:102) ~[classes/:na]
at ****.java:52) ~[classes/:na]
at sun.reflect.GeneratedMethodAccessor81.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_201]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_201]
at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:93) [spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_201]
at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266) [na:1.8.0_201]
at java.util.concurrent.FutureTask.run(FutureTask.java) [na:1.8.0_201]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_201]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [na:1.8.0_201]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_201]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_201]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_201]
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)
- init a api resource with gateway rule manager
- update that before that has been requested
Tell us your environment
Sentinel Version : 1.8
Anything else we need to know?
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?