From cd7c34f9b4005d27886f73e58bef88e706fcccf9 Mon Sep 17 00:00:00 2001 From: Wei-Chiu Chuang Date: Fri, 24 Sep 2021 23:35:23 +0800 Subject: [PATCH] HDFS-16233. Do not use exception handler to implement copy-on-write for EnumCounters. (#3468) (cherry picked from commit 87632bbacf064e9b07564ba66ed1fbb1d42290d1) (cherry picked from commit bb08de559a36fd56c7d4023c6dcac66da3fbacc5) (cherry picked from commit 978ec57445f4178b31a6bfc383c6be032692c288) --- .../apache/hadoop/hdfs/server/namenode/QuotaCounts.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) 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 bcb21929c8b9f..d5387d1093559 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; }