[
https://issues.apache.org/jira/browse/HDFS-16733?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17583651#comment-17583651
]
ASF GitHub Bot commented on HDFS-16733:
---------------------------------------
Hexiaoqiao commented on code in PR #4761:
URL: https://github.com/apache/hadoop/pull/4761#discussion_r952681531
##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INode.java:
##########
@@ -73,7 +73,8 @@ public abstract class INode implements INodeAttributes,
Diff.Element<byte[]> {
* Check whether this is the root inode.
*/
final boolean isRoot() {
- return getLocalNameBytes().length == 0;
+ // Note: There is no restriction that id must be equal to
INodeId#ROOT_INODE_ID
+ return getLocalNameBytes() == null || getLocalNameBytes().length == 0;
Review Comment:
Got it. If that is true, I think we should submit PR to branch FGL first?
Thanks.
> Improve INode#isRoot()
> ----------------------
>
> Key: HDFS-16733
> URL: https://issues.apache.org/jira/browse/HDFS-16733
> Project: Hadoop HDFS
> Issue Type: Bug
> Components: namenode
> Affects Versions: 3.3.0
> Reporter: JiangHua Zhu
> Assignee: JiangHua Zhu
> Priority: Major
> Labels: pull-request-available
>
> When constructing an INodeFile or INodeDirectory, it is usually necessary to
> give a name. For getLocalNameBytes, there are not many restrictions, such as
> null can be set. But an exception is thrown:
> {code:java}
> INodeDirectory root = new INodeDirectory(HdfsConstants.GRANDFATHER_INODE_ID,
> null, perm, 0L);
> {code}
> Some exceptions:
> {code:java}
> java.lang.NullPointerException
> at org.apache.hadoop.hdfs.server.namenode.INode.isRoot(INode.java:78)
> {code}
> Although these situations rarely occur in production environments, we should
> refine the implementation of isRoot() to avoid this exception. This can
> enhance system robustness.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]