[ https://issues.apache.org/jira/browse/HDFS-14172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16762398#comment-16762398 ]
Xiang Li commented on HDFS-14172: --------------------------------- [~adam.antal] Would you please check patch 004 ? I removed the "else" clause so as not to change the indentation. The patch is focusing on the change now. > Avoid NPE when SectionName#fromString() returns null > ---------------------------------------------------- > > Key: HDFS-14172 > URL: https://issues.apache.org/jira/browse/HDFS-14172 > Project: Hadoop HDFS > Issue Type: Improvement > Reporter: Xiang Li > Assignee: Xiang Li > Priority: Minor > Attachments: HADOOP-14172.000.patch, HADOOP-14172.001.patch, > HADOOP-14172.002.patch, HADOOP-14172.003.patch > > > In FSImageFormatProtobuf.SectionName#fromString(), as follows: > {code:java} > public static SectionName fromString(String name) { > for (SectionName n : values) { > if (n.name.equals(name)) > return n; > } > return null; > } > {code} > When the code meets an unknown section from the fsimage, the function will > return null. Callers always operates the return value with a "switch" clause, > like FSImageFormatProtobuf.Loader#loadInternal(), as: > {code:java} > switch (SectionName.fromString(n)) > {code} > NPE will be thrown here. -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org