[ 
https://issues.apache.org/jira/browse/HDFS-14172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16728581#comment-16728581
 ] 

Xiang Li edited comment on HDFS-14172 at 12/25/18 3:44 AM:
-----------------------------------------------------------

We met the NPE under the scenario that: we applied the patch of HDFS-7076, to 
allow users to add custom storage polices. It will add new section called 
"STORAGE_POLICIES" into fsimage. When we fall back to use the code without 
HDFS-7076, NameNode could not get started due to NPE, and Offline Image Viewer 
has the same error, like:
{code}
DEBUG offlineImageViewer.FSImageHandler: Loading section STORAGE_POLICIES 
length: 149
Exception in thread "main" java.lang.NullPointerException
        at 
org.apache.hadoop.hdfs.tools.offlineImageViewer.FSImageLoader.load(FSImageLoader.java:152)
        at 
org.apache.hadoop.hdfs.tools.offlineImageViewer.WebImageViewer.initServer(WebImageViewer.java:90)
        at 
org.apache.hadoop.hdfs.tools.offlineImageViewer.WebImageViewer.start(WebImageViewer.java:74)
        at 
org.apache.hadoop.hdfs.tools.offlineImageViewer.OfflineImageViewerPB.run(OfflineImageViewerPB.java:176)
        at 
org.apache.hadoop.hdfs.tools.offlineImageViewer.OfflineImageViewerPB.main(OfflineImageViewerPB.java:124)
{code}


was (Author: water):
We met the NPE under the scenario that: we applied the patch of HDFS-7076, to 
allow users to add custom storage polices. It will add new section called 
"STORAGE_POLICIES" into fsimage. When we fall back to use the code without 
HDFS-7076, NameNode could not get started due to NPE, and Offline Image Viewer 
has the same error, like:
{code}
DEBUG offlineImageViewer.FSImageHandler: Loading section STORAGE_POLICIES 
length: 149
{code}

> Return a default SectionName to avoid NPE
> -----------------------------------------
>
>                 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
>
> 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.
> Shall we add a default section name in the enum of SectionName, like 
> "UNKNOWN", to steer clear of NPE?



--
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

Reply via email to