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); }