HBASE-21204 NPE when scan raw DELETE_FAMILY_VERSION and codec is not set

Signed-off-by: tedyu <yuzhihong@gmail.com>
This commit is contained in:
tianjingyun 2018-09-20 09:17:52 +08:00 committed by tedyu
parent e6c7ed34e0
commit c5af7b654b
3 changed files with 28 additions and 0 deletions

View File

@ -32,6 +32,7 @@ enum CellType {
PUT = 4; PUT = 4;
DELETE = 8; DELETE = 8;
DELETE_FAMILY_VERSION = 10;
DELETE_COLUMN = 12; DELETE_COLUMN = 12;
DELETE_FAMILY = 14; DELETE_FAMILY = 14;

View File

@ -32,6 +32,7 @@ enum CellType {
PUT = 4; PUT = 4;
DELETE = 8; DELETE = 8;
DELETE_FAMILY_VERSION = 10;
DELETE_COLUMN = 12; DELETE_COLUMN = 12;
DELETE_FAMILY = 14; DELETE_FAMILY = 14;

View File

@ -17,6 +17,8 @@
*/ */
package org.apache.hadoop.hbase.client; package org.apache.hadoop.hbase.client;
import static org.apache.hadoop.hbase.HConstants.RPC_CODEC_CONF_KEY;
import static org.apache.hadoop.hbase.ipc.RpcClient.DEFAULT_CODEC_CLASS;
import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
@ -608,6 +610,30 @@ public class TestScannersFromClientSide {
"Testing offset + multiple CFs + maxResults"); "Testing offset + multiple CFs + maxResults");
} }
@Test
public void testScanRawDeleteFamilyVersion() throws Exception {
TableName tableName = TableName.valueOf(name.getMethodName());
TEST_UTIL.createTable(tableName, FAMILY);
Configuration conf = new Configuration(TEST_UTIL.getConfiguration());
conf.set(RPC_CODEC_CONF_KEY, "");
conf.set(DEFAULT_CODEC_CLASS, "");
try (Connection connection = ConnectionFactory.createConnection(conf);
Table table = connection.getTable(tableName)) {
Delete delete = new Delete(ROW);
delete.addFamilyVersion(FAMILY, 0L);
table.delete(delete);
Scan scan = new Scan(ROW).setRaw(true);
ResultScanner scanner = table.getScanner(scan);
int count = 0;
while (scanner.next() != null) {
count++;
}
assertEquals(1, count);
} finally {
TEST_UTIL.deleteTable(tableName);
}
}
/** /**
* Test from client side for scan while the region is reopened * Test from client side for scan while the region is reopened
* on the same region server. * on the same region server.