diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/QuotaCounts.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/QuotaCounts.java index 002972caf6..00e848f05a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/QuotaCounts.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/QuotaCounts.java @@ -23,7 +23,6 @@ import org.apache.hadoop.hdfs.protocol.HdfsConstants; import org.apache.hadoop.hdfs.util.ConstEnumCounters; import org.apache.hadoop.hdfs.util.EnumCounters; -import org.apache.hadoop.hdfs.util.ConstEnumCounters.ConstEnumException; import java.util.function.Consumer; @@ -57,14 +56,10 @@ public class QuotaCounts { */ static > EnumCounters modify(EnumCounters counter, Consumer> action) { - try { - action.accept(counter); - } catch (ConstEnumException cee) { - // We don't call clone here because ConstEnumCounters.clone() will return - // an object of class ConstEnumCounters. We want EnumCounters. + if (counter instanceof ConstEnumCounters) { counter = counter.deepCopyEnumCounter(); - action.accept(counter); } + action.accept(counter); return counter; }