diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/MetaTableMetrics.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/MetaTableMetrics.java index db97789810d..12a969bca5f 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/MetaTableMetrics.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/MetaTableMetrics.java @@ -294,9 +294,8 @@ public class MetaTableMetrics extends BaseRegionObserver { public void start(CoprocessorEnvironment env) throws IOException { if (env instanceof RegionCoprocessorEnvironment && ((RegionCoprocessorEnvironment) env).getRegionInfo().getTable() != null - && ((RegionCoprocessorEnvironment) env).getRegionInfo().getTable().getName() != null - && new String(((RegionCoprocessorEnvironment) env).getRegionInfo().getTable().getName(), - StandardCharsets.UTF_8).equals(TableName.META_TABLE_NAME.toString())) { + && ((RegionCoprocessorEnvironment) env).getRegionInfo().getTable() + .equals(TableName.META_TABLE_NAME)) { regionCoprocessorEnv = (RegionCoprocessorEnvironment) env; requestsMap = new ConcurrentHashMap<>(); clientMetricsLossyCounting = new LossyCounting(); @@ -306,11 +305,13 @@ public class MetaTableMetrics extends BaseRegionObserver { } @Override - public void stop(CoprocessorEnvironment e) throws IOException { + public void stop(CoprocessorEnvironment env) throws IOException { // since meta region can move around, clear stale metrics when stop. - for (String meterName : requestsMap.keySet()) { - MetricRegistry registry = regionCoprocessorEnv.getMetricRegistryForRegionServer(); - registry.remove(meterName); + if (requestsMap != null) { + for (String meterName : requestsMap.keySet()) { + MetricRegistry registry = regionCoprocessorEnv.getMetricRegistryForRegionServer(); + registry.remove(meterName); + } } }