diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/metric/MetricTimerListener.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/metric/MetricTimerListener.java index 93992cc9..9dda6c83 100755 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/metric/MetricTimerListener.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/metric/MetricTimerListener.java @@ -62,9 +62,7 @@ public class MetricTimerListener implements Runnable { MetricNode metricNode = entry.getValue(); metricNode.setResource(node.getName()); metricNode.setClassification(node.getResourceType()); - if (maps.get(time) == null) { - maps.put(time, new ArrayList()); - } + maps.computeIfAbsent(time, k -> new ArrayList()); List nodes = maps.get(time); nodes.add(entry.getValue()); } diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/FlowRuleManager.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/FlowRuleManager.java index eda0faaf..9dfa3f27 100755 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/FlowRuleManager.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/FlowRuleManager.java @@ -77,7 +77,7 @@ public class FlowRuleManager { private static void startMetricTimerListener() { long flushInterval = SentinelConfig.metricLogFlushIntervalSec(); if (flushInterval <= 0) { - RecordLog.info("[FlowRuleManager] The MetricTimerListener is'n started. If you want to start it, " + RecordLog.info("[FlowRuleManager] The MetricTimerListener isn't started. If you want to start it, " + "please change the value(current: {}) of config({}) more than 0 to start it.", flushInterval, SentinelConfig.METRIC_FLUSH_INTERVAL); return;