diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientScanner.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientScanner.java index 3550e6c1a74..562cb56aff8 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientScanner.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientScanner.java @@ -573,7 +573,8 @@ public class ClientScanner extends AbstractClientScanner { // the caller will receive a result back where the number of cells in the result is less than // the batch size even though it may not be the last group of cells for that row. if (allowPartials || isBatchSet) { - addResultsToList(resultsToAddToCache, resultsFromServer, 0, resultsFromServer.length); + addResultsToList(resultsToAddToCache, resultsFromServer, 0, + (null == resultsFromServer ? 0 : resultsFromServer.length)); return resultsToAddToCache; } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java index 02eca778bdd..0b793b441ea 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java @@ -72,6 +72,8 @@ import org.apache.hadoop.hbase.filter.CompareFilter; import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp; import org.apache.hadoop.hbase.filter.Filter; import org.apache.hadoop.hbase.filter.FilterList; +import org.apache.hadoop.hbase.filter.FirstKeyOnlyFilter; +import org.apache.hadoop.hbase.filter.InclusiveStopFilter; import org.apache.hadoop.hbase.filter.KeyOnlyFilter; import org.apache.hadoop.hbase.filter.LongComparator; import org.apache.hadoop.hbase.filter.PrefixFilter; @@ -6415,4 +6417,17 @@ public class TestFromClientSide { } } } + + @Test + public void testFilterAllRecords() throws IOException { + Scan scan = new Scan(); + scan.setBatch(1); + scan.setCaching(1); + // Filter out any records + scan.setFilter(new FilterList(new FirstKeyOnlyFilter(), new InclusiveStopFilter(new byte[0]))); + Table table = TEST_UTIL.getConnection().getTable(TableName.NAMESPACE_TABLE_NAME); + ResultScanner s = table.getScanner(scan); + assertNull(s.next()); + table.close(); + } }