diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java index ca4f9b04d62..7efda865525 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java @@ -233,6 +233,9 @@ public class MultiRowRangeFilter extends FilterBase { if (insertionPosition == 0 && !rangeList.get(insertionPosition).contains(rowKey)) { return ROW_BEFORE_FIRST_RANGE; } + if (!initialized) { + initialized = true; + } return insertionPosition; } // the row key equals one of the start keys, and the the range exclude the start key diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java index 0c596aae4ce..dfa8bfa459d 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java @@ -69,6 +69,24 @@ public class TestMultiRowRangeFilter { TEST_UTIL.shutdownMiniCluster(); } + @Test + public void testRanges() throws IOException { + byte[] key1Start = new byte[] {-3}; + byte[] key1End = new byte[] {-2}; + + byte[] key2Start = new byte[] {5}; + byte[] key2End = new byte[] {6}; + + byte[] badKey = new byte[] {-10}; + + MultiRowRangeFilter filter = new MultiRowRangeFilter(Arrays.asList( + new MultiRowRangeFilter.RowRange(key1Start, true, key1End, false), + new MultiRowRangeFilter.RowRange(key2Start, true, key2End, false) + )); + filter.filterRowKey(badKey, 0, 1); + assertEquals(Filter.ReturnCode.SEEK_NEXT_USING_HINT, filter.filterKeyValue(null)); + } + @Test public void testOutOfOrderScannerNextException() throws Exception { MultiRowRangeFilter filter = new MultiRowRangeFilter(Arrays.asList(