HBASE-25644 Scan#setSmall blindly sets ReadType as PREAD

Signed-off-by: zhangduo <zhangduo@apache.org>
Signed-off-by: Ramkrishna <ramkrishna@apache.org>
This commit is contained in:
Anoop Sam John 2021-03-08 12:44:07 +05:30 committed by GitHub
parent 190c253c4e
commit 53128fe7c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -895,7 +895,9 @@ public class Scan extends Query {
@Deprecated @Deprecated
public Scan setSmall(boolean small) { public Scan setSmall(boolean small) {
this.small = small; this.small = small;
if (small) {
this.readType = ReadType.PREAD; this.readType = ReadType.PREAD;
}
return this; return this;
} }

View File

@ -18,6 +18,7 @@
package org.apache.hadoop.hbase.client; package org.apache.hadoop.hbase.client;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; 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", assertTrue("Make sure copy constructor adds all the fields in the copied object",
EqualsBuilder.reflectionEquals(scan, scanCopy)); 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());
}
} }