You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by xk...@apache.org on 2021/09/24 15:35:40 UTC

[hadoop] branch trunk updated: HDFS-16233. Do not use exception handler to implement copy-on-write for EnumCounters. (#3468)

This is an automated email from the ASF dual-hosted git repository.

xkrogen pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 87632bb  HDFS-16233. Do not use exception handler to implement copy-on-write for EnumCounters. (#3468)
87632bb is described below

commit 87632bbacf064e9b07564ba66ed1fbb1d42290d1
Author: Wei-Chiu Chuang <we...@apache.org>
AuthorDate: Fri Sep 24 23:35:23 2021 +0800

    HDFS-16233. Do not use exception handler to implement copy-on-write for EnumCounters. (#3468)
---
 .../java/org/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 d1b777c..455a74e 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.fs.StorageType;
 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 <T extends Enum<T>> EnumCounters<T> modify(EnumCounters<T> counter,
       Consumer<EnumCounters<T>> 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;
   }
 

---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org