diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystemLock.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystemLock.java index e510bd625e738..bdf7f68343b68 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystemLock.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystemLock.java @@ -32,6 +32,7 @@ import org.apache.hadoop.ipc.Server; import org.apache.hadoop.log.LogThrottlingHelper; import org.apache.hadoop.metrics2.lib.MutableRatesWithAggregation; +import org.apache.hadoop.util.Preconditions; import org.apache.hadoop.util.StringUtils; import org.apache.hadoop.util.Time; import org.apache.hadoop.util.Timer; @@ -160,6 +161,10 @@ public Long initialValue() { FSNamesystem.LOG.info("Detailed lock hold time metrics enabled: " + this.metricsEnabled); this.detailedHoldTimeMetrics = detailedHoldTimeMetrics; + if (metricsEnabled) { + Preconditions.checkArgument(detailedHoldTimeMetrics != null, + "Detailed lock hold time metrics enabled, detailed hold time metric should not be null!"); + } } public void readLock() {