From 53128fe7c17e6220113884fbad69d75c59ed56b7 Mon Sep 17 00:00:00 2001 From: Anoop Sam John Date: Mon, 8 Mar 2021 12:44:07 +0530 Subject: [PATCH] HBASE-25644 Scan#setSmall blindly sets ReadType as PREAD Signed-off-by: zhangduo Signed-off-by: Ramkrishna --- .../java/org/apache/hadoop/hbase/client/Scan.java | 4 +++- .../org/apache/hadoop/hbase/client/TestScan.java | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Scan.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Scan.java index 708d6c73569..0be51c41efc 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Scan.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Scan.java @@ -895,7 +895,9 @@ public class Scan extends Query { @Deprecated public Scan setSmall(boolean small) { this.small = small; - this.readType = ReadType.PREAD; + if (small) { + this.readType = ReadType.PREAD; + } return this; } diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestScan.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestScan.java index b0f6b196b10..941bcabddfb 100644 --- a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestScan.java +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestScan.java @@ -18,6 +18,7 @@ package org.apache.hadoop.hbase.client; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -292,4 +293,15 @@ public class TestScan { assertTrue("Make sure copy constructor adds all the fields in the copied object", EqualsBuilder.reflectionEquals(scan, scanCopy)); } + + @Test + public void testScanReadType() throws Exception { + Scan scan = new Scan(); + assertFalse(scan.isSmall()); + assertEquals(ReadType.DEFAULT, scan.getReadType()); + Scan copyScan = new Scan(scan); + copyScan.setSmall(scan.isSmall()); + assertFalse(copyScan.isSmall()); + assertEquals(ReadType.DEFAULT, copyScan.getReadType()); + } }