浏览代码

HADOOP-1941 StopRowFilter throws NPE when passed null row

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@579410 13f79535-47bb-0310-9956-ffa450edef68
Michael Stack 18 年之前
父节点
当前提交
6f683d0b64

+ 1 - 0
src/contrib/hbase/CHANGES.txt

@@ -61,6 +61,7 @@ Trunk (unreleased changes)
     HADOOP-1923, HADOOP-1924 a) tests fail sporadically because set up and tear
                  down is inconsistent b) TestDFSAbort failed in nightly #242
     HADOOP-1929 Add hbase-default.xml to hbase jar
+    HADOOP-1941 StopRowFilter throws NPE when passed null row
 
   IMPROVEMENTS
     HADOOP-1737 Make HColumnDescriptor data publically members settable

+ 6 - 0
src/contrib/hbase/src/java/org/apache/hadoop/hbase/filter/StopRowFilter.java

@@ -98,6 +98,12 @@ public class StopRowFilter implements RowFilterInterface {
 
   /** {@inheritDoc} */
   public boolean filter(final Text rowKey) {
+    if (rowKey == null) {
+      if (this.stopRowKey == null) {
+        return true;
+      }
+      return false;
+    }
     boolean result = this.stopRowKey.compareTo(rowKey) <= 0;
     if (LOG.isDebugEnabled()) {
       LOG.debug("Filter result for rowKey: " + rowKey + ".  Result: " + 

+ 2 - 0
src/contrib/hbase/src/test/org/apache/hadoop/hbase/filter/TestStopRowFilter.java

@@ -87,5 +87,7 @@ public class TestStopRowFilter extends TestCase {
 
     assertFalse("FilterAllRemaining", filter.filterAllRemaining());
     assertFalse("FilterNotNull", filter.filterNotNull(null));
+    
+    assertFalse("Filter a null", filter.filter(null));
   }
 }