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

Nihal Jain commented on HBASE-20340:
------------------------------------

In  [^HBASE-20340-master.001.patch] we're doing {{rs.listCells()}} twice. Can 
we return null after performing {{rs.listCells()}} in the existing code?


> potential null pointer exception in 
> org.apache.hadoop.hbase.rest.TableScanResource given empty resource
> -------------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-20340
>                 URL: https://issues.apache.org/jira/browse/HBASE-20340
>             Project: HBase
>          Issue Type: Bug
>          Components: hbase
>    Affects Versions: 2.0.0-beta-2
>            Reporter: andy zhou
>            Assignee: Xu Cang
>            Priority: Minor
>         Attachments: HBASE-20340-master.001.patch
>
>
> Our code analyzer has detected a potential null pointer issue in 
> org.apache.hadoop.hbase.rest.TableScanResource as follows:
> {code:java}
> // org.apache.hadoop.hbase.client.Result.java Line #244 
> public List<Cell> listCells() {
>     return isEmpty()? null: Arrays.asList(rawCells());
> }
> {code}
> {code:java}
> // org.apache.hadoop.hbase.rest.TableScanResource Line #95
> List<Cell> kvs = rs.listCells(); 
> for (Cell kv : kvs) { ... }
> {code}
>  
> Given empty rs, kvs shall be null instead of an empty list, leading to 
> potential null pointer exception
>  
> (org.apache.hadoop.hbase.client.Result.java Line #244 and 
> org.apache.hadoop.hbase.rest.TableScanResource Line #95
> Linkage to the code is here:
> https://github.com/apache/hbase/blob/9e9b347d667e1fc6165c9f8ae5ae7052147e8895/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java#L244
> SourceBrella Inc.
> https://github.com/apache/hbase/blob/9e9b347d667e1fc6165c9f8ae5ae7052147e8895/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/TableScanResource.java#L95



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to