[ 
https://issues.apache.org/jira/browse/HDFS-13451?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

lujie updated HDFS-13451:
-------------------------
    Description: 
We have developed a static analysis tool 
[NPEDetector|https://github.com/lujiefsi/NPEDetector] to find some potential 
NPE. Our analysis shows that some callees may return null in corner case(e.g. 
node crash , IO exception), 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:

callee BlockInfo#getDatanode may return null:
{code:java}
public DatanodeDescriptor getDatanode(int index) {
    DatanodeStorageInfo storage = getStorageInfo(index);
   return storage == null ? null : storage.getDatanodeDescriptor();
}
{code}
it has 4 callers, 3 of them have !=null checker, like in 
CacheReplicationMonitor#addNewPendingCached:
{code:java}
DatanodeDescriptor datanode = blockInfo.getDatanode(i);
if (datanode == null) {
   continue;
}
{code}
but in caller NamenodeFsck#blockIdCK have no !null checker, we add checker just 
like CacheReplicationMonitor#addNewPendingCached
{code:java}
DatanodeDescriptor dn = blockInfo.getDatanode(idx);
if (dn == null) {
    continue;
}
{code}
But due to we are not very  familiar with HDFS, hope some expert can review it.

Thanks!!!!

  was:
We have developed a static analysis tool 
[NPEDetector|https://github.com/lujiefsi/NPEDetector] to find some potential 
NPE. Our analysis shows that some callees may return null in corner case(e.g. 
node crash , IO exception), 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:

callee BlockInfo#getDatanode may return null:
{code:java}
public DatanodeDescriptor getDatanode(int index) {
    DatanodeStorageInfo storage = getStorageInfo(index);
   return storage == null ? null : storage.getDatanodeDescriptor();
}
{code}
it has 4 callers, 3 of them have !=null checker, like in 
CacheReplicationMonitor#addNewPendingCached:
{code:java}
DatanodeDescriptor datanode = blockInfo.getDatanode(i);
if (datanode == null) {
   continue;
}
{code}
but in caller NamenodeFsck#blockIdCK have no !null checker, we add checker just 
like CacheReplicationMonitor#addNewPendingCached
{code:java}
DatanodeDescriptor dn = blockInfo.getDatanode(idx);
if (dn == null) {
    continue;
}
{code}
But due to we are not very  familiar with CASSANDRA, hope some expert can 
review it.

Thanks!!!!


> Fix Some Potential NPE
> ----------------------
>
>                 Key: HDFS-13451
>                 URL: https://issues.apache.org/jira/browse/HDFS-13451
>             Project: Hadoop HDFS
>          Issue Type: Bug
>    Affects Versions: 3.0.0-beta1
>            Reporter: lujie
>            Priority: Major
>         Attachments: HDFS-13451_1.patch
>
>
> We have developed a static analysis tool 
> [NPEDetector|https://github.com/lujiefsi/NPEDetector] to find some potential 
> NPE. Our analysis shows that some callees may return null in corner case(e.g. 
> node crash , IO exception), 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:
> callee BlockInfo#getDatanode may return null:
> {code:java}
> public DatanodeDescriptor getDatanode(int index) {
>     DatanodeStorageInfo storage = getStorageInfo(index);
>    return storage == null ? null : storage.getDatanodeDescriptor();
> }
> {code}
> it has 4 callers, 3 of them have !=null checker, like in 
> CacheReplicationMonitor#addNewPendingCached:
> {code:java}
> DatanodeDescriptor datanode = blockInfo.getDatanode(i);
> if (datanode == null) {
>    continue;
> }
> {code}
> but in caller NamenodeFsck#blockIdCK have no !null checker, we add checker 
> just like CacheReplicationMonitor#addNewPendingCached
> {code:java}
> DatanodeDescriptor dn = blockInfo.getDatanode(idx);
> if (dn == null) {
>     continue;
> }
> {code}
> But due to we are not very  familiar with HDFS, hope some expert can review 
> it.
> Thanks!!!!



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