Skip to content

Commit

Permalink
HDFS-16233. Do not use exception handler to implement copy-on-write f…
Browse files Browse the repository at this point in the history
…or EnumCounters. (#3468)

(cherry picked from commit 87632bb)
(cherry picked from commit bb08de5)
(cherry picked from commit 978ec57)
  • Loading branch information
jojochuang authored and xkrogen committed Sep 24, 2021
1 parent 043c380 commit cd7c34f
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit cd7c34f

Please sign in to comment.