diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java index b8903754155..f541da50e4a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java @@ -1423,8 +1423,8 @@ public class FSDirectory implements Closeable { HdfsFileStatus listing[] = new HdfsFileStatus[numOfListing]; for (int i=0; i0; i++) { INode cur = contents.get(startChild+i); - byte curPolicy = isSuperUser ? cur.getLocalStoragePolicyID() : - BlockStoragePolicy.ID_UNSPECIFIED; + byte curPolicy = isSuperUser && !cur.isSymlink()? + cur.getLocalStoragePolicyID(): BlockStoragePolicy.ID_UNSPECIFIED; listing[i] = createFileStatus(cur.getLocalNameBytes(), cur, needLocation, getStoragePolicyID(curPolicy, parentStoragePolicy), snapshot, isRawPath); @@ -1503,7 +1503,7 @@ public class FSDirectory implements Closeable { } final INodesInPath inodesInPath = getLastINodeInPath(srcs, resolveLink); final INode i = inodesInPath.getINode(0); - byte policyId = includeStoragePolicy && i != null ? + byte policyId = includeStoragePolicy && i != null && !i.isSymlink() ? i.getStoragePolicyID() : BlockStoragePolicy.ID_UNSPECIFIED; return i == null ? null : createFileStatus(HdfsFileStatus.EMPTY_NAME, i, policyId, inodesInPath.getPathSnapshotId(), isRawPath);