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

Mingliang Liu commented on HDFS-7101:
-------------------------------------

This is a good catch, and the initial value makes sense to me.

If {{readLine()}} throws exception, the following code {{if 
(lastLine.endsWith(...)}} will not reach as we don't swallow the exception 
here. I think NPE that is caused by {{lastLine}} only happens if the input 
stream is empty. Agreed? 

> Potential null dereference in DFSck#doWork()
> --------------------------------------------
>
>                 Key: HDFS-7101
>                 URL: https://issues.apache.org/jira/browse/HDFS-7101
>             Project: Hadoop HDFS
>          Issue Type: Bug
>    Affects Versions: 2.5.1
>            Reporter: Ted Yu
>            Assignee: skrho
>            Priority: Minor
>              Labels: BB2015-05-TBR
>         Attachments: HDFS-7101.v1.patch, HDFS-7101_001.patch
>
>
> {code}
>     String lastLine = null;
>     int errCode = -1;
>     try {
>       while ((line = input.readLine()) != null) {
> ...
>     if (lastLine.endsWith(NamenodeFsck.HEALTHY_STATUS)) {
>       errCode = 0;
> {code}
> If readLine() throws exception, lastLine may be null, leading to NPE.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to