diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java index 965aa34b5b0..326e78abf6d 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java @@ -939,9 +939,7 @@ public final class ProtobufUtil { if (!scan.includeStartRow()) { scanBuilder.setIncludeStartRow(false); } - if (scan.includeStopRow()) { - scanBuilder.setIncludeStopRow(true); - } + scanBuilder.setIncludeStopRow(scan.includeStopRow()); if (scan.getReadType() != Scan.ReadType.DEFAULT) { scanBuilder.setReadType(toReadType(scan.getReadType())); } diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java index ee60d87af0f..3039392f608 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java @@ -1082,9 +1082,7 @@ public final class ProtobufUtil { if (!scan.includeStartRow()) { scanBuilder.setIncludeStartRow(false); } - if (scan.includeStopRow()) { - scanBuilder.setIncludeStopRow(true); - } + scanBuilder.setIncludeStopRow(scan.includeStopRow()); if (scan.getReadType() != Scan.ReadType.DEFAULT) { scanBuilder.setReadType(toReadType(scan.getReadType())); } diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/shaded/protobuf/TestProtobufUtil.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/shaded/protobuf/TestProtobufUtil.java index be51e96940e..2d8a74af113 100644 --- a/hbase-client/src/test/java/org/apache/hadoop/hbase/shaded/protobuf/TestProtobufUtil.java +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/shaded/protobuf/TestProtobufUtil.java @@ -246,6 +246,7 @@ public class TestProtobufUtil { scanBuilder.setCacheBlocks(false); scanBuilder.setCaching(1024); scanBuilder.setTimeRange(ProtobufUtil.toTimeRange(TimeRange.allTime())); + scanBuilder.setIncludeStopRow(false); ClientProtos.Scan expectedProto = scanBuilder.build(); ClientProtos.Scan actualProto = ProtobufUtil.toScan( diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java index fad4f4516fa..d55ce1bad05 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java @@ -1090,7 +1090,7 @@ public class TestFromClientSide3 { } Scan scan = new Scan(); - scan.withStartRow(ROW).withStopRow(ROW).addFamily(FAMILY).setBatch(3) + scan.withStartRow(ROW).withStopRow(ROW, true).addFamily(FAMILY).setBatch(3) .setMaxResultSize(4 * 1024 * 1024); Result result; try (ResultScanner scanner = table.getScanner(scan)) { @@ -1113,7 +1113,7 @@ public class TestFromClientSide3 { } scan = new Scan(); - scan.withStartRow(ROW).withStopRow(ROW).addFamily(FAMILY).setBatch(2) + scan.withStartRow(ROW).withStopRow(ROW, true).addFamily(FAMILY).setBatch(2) .setMaxResultSize(4 * 1024 * 1024); try (ResultScanner scanner = table.getScanner(scan)) { List list = new ArrayList<>(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannersFromClientSide.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannersFromClientSide.java index 5e8d107d4f5..b91e205d428 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannersFromClientSide.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannersFromClientSide.java @@ -22,6 +22,7 @@ import static org.apache.hadoop.hbase.ipc.RpcClient.DEFAULT_CODEC_CLASS; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -897,4 +898,41 @@ public class TestScannersFromClientSide { } } } + + @Test + public void testScanWithSameStartRowStopRow() throws IOException { + TableName tableName = TableName.valueOf(name.getMethodName()); + try (Table table = TEST_UTIL.createTable(tableName, FAMILY)) { + table.put(new Put(ROW).addColumn(FAMILY, QUALIFIER, VALUE)); + + Scan scan = new Scan().withStartRow(ROW).withStopRow(ROW); + try (ResultScanner scanner = table.getScanner(scan)) { + assertNull(scanner.next()); + } + + scan = new Scan().withStartRow(ROW, true).withStopRow(ROW, true); + try (ResultScanner scanner = table.getScanner(scan)) { + Result result = scanner.next(); + assertNotNull(result); + assertArrayEquals(ROW, result.getRow()); + assertArrayEquals(VALUE, result.getValue(FAMILY, QUALIFIER)); + assertNull(scanner.next()); + } + + scan = new Scan().withStartRow(ROW, true).withStopRow(ROW, false); + try (ResultScanner scanner = table.getScanner(scan)) { + assertNull(scanner.next()); + } + + scan = new Scan().withStartRow(ROW, false).withStopRow(ROW, false); + try (ResultScanner scanner = table.getScanner(scan)) { + assertNull(scanner.next()); + } + + scan = new Scan().withStartRow(ROW, false).withStopRow(ROW, true); + try (ResultScanner scanner = table.getScanner(scan)) { + assertNull(scanner.next()); + } + } + } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestProtobufUtil.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestProtobufUtil.java index 300f0292afe..ff29df838b5 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestProtobufUtil.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestProtobufUtil.java @@ -319,6 +319,7 @@ public class TestProtobufUtil { scanBuilder.setCacheBlocks(false); scanBuilder.setCaching(1024); scanBuilder.setTimeRange(ProtobufUtil.toTimeRange(TimeRange.allTime())); + scanBuilder.setIncludeStopRow(false); ClientProtos.Scan expectedProto = scanBuilder.build(); ClientProtos.Scan actualProto = ProtobufUtil.toScan(