HDFS-14009. HttpFS: FileStatus#setSnapShotEnabledFlag throws InvocationTargetException when attribute set is emptySet. Contributed by Siyao Meng.

Signed-off-by: Wei-Chiu Chuang <weichiu@apache.org>
This commit is contained in:
Siyao Meng 2018-10-18 17:02:04 -07:00 committed by Wei-Chiu Chuang
parent b34c650a41
commit 6a7bf9f850
1 changed files with 5 additions and 1 deletions

View File

@ -360,7 +360,11 @@ public class FileStatus implements Writable, Comparable<Object>,
*/
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);
}