diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeDirectory.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeDirectory.java index b592c3ff896..85d5a45344a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeDirectory.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeDirectory.java @@ -841,7 +841,8 @@ public class INodeDirectory extends INodeWithAdditionalFields // If the inode has empty diff list and sf is not a // DirectorySnapshottableFeature, remove the feature to save heap. if (sf.getDiffs().isEmpty() && - !(sf instanceof DirectorySnapshottableFeature)) { + !(sf instanceof DirectorySnapshottableFeature) && + getDirectoryWithSnapshotFeature() != null) { this.removeFeature(sf); } } else {