GitHub user brettKK opened a pull request:

    https://github.com/apache/helix/pull/200

    throw new Exception to avoid ugly NPE

    We have developed a static analysis tool NPEDetector to find some potential 
NPE. Our analysis shows that some callees may return null in corner case(e.g. 
node crash , IOException), some of their callers have  !=null check but some do 
not have. In this issue we post a patch which can add  !=null  based on existed 
!=null  check. For example:
    
    ZkGrep#parseZkSnapshot:
    ```
      return retFiles;
    } catch (Exception e) {
      LOG.error("fail to parse zkSnapshot: " + lastZkSnapshot, e);
    }
    
    return null;
    ```
    So parseZkSnapshot will return null while IOException happens. but its 
caller ZkGrep#processCommandLineArgs have no null checker:
    ```
    File[] lastZkSnapshot = parseZkSnapshot(zkDataDirs[1], byTime);
    
    // lastZkSnapshot[1] is the parsed last snapshot by byTime
    grepZkSnapshot(lastZkSnapshot[1], patterns);
    ```
    We should terminate the process while  lastZkSnapshot == null 

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/brettKK/helix HELIX-701

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/helix/pull/200.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #200
    
----

----


---

Reply via email to