From 6a7bf9f850b560eb01b2db78d04446c74b443b8f Mon Sep 17 00:00:00 2001 From: Siyao Meng Date: Thu, 18 Oct 2018 17:02:04 -0700 Subject: [PATCH] HDFS-14009. HttpFS: FileStatus#setSnapShotEnabledFlag throws InvocationTargetException when attribute set is emptySet. Contributed by Siyao Meng. Signed-off-by: Wei-Chiu Chuang --- .../src/main/java/org/apache/hadoop/fs/FileStatus.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileStatus.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileStatus.java index bdfbd20be8c..4d953c69d2c 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileStatus.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileStatus.java @@ -360,7 +360,11 @@ public class FileStatus implements Writable, Comparable, */ public void setSnapShotEnabledFlag(boolean isSnapShotEnabled) { if (isSnapShotEnabled) { - attr.add(AttrFlags.SNAPSHOT_ENABLED); + if (attr == NONE) { + attr = EnumSet.of(AttrFlags.SNAPSHOT_ENABLED); + } else { + attr.add(AttrFlags.SNAPSHOT_ENABLED); + } } else { attr.remove(AttrFlags.SNAPSHOT_ENABLED); }