From c5af7b654b66ee0561de7f5490a95dec84205669 Mon Sep 17 00:00:00 2001 From: tianjingyun Date: Thu, 20 Sep 2018 09:17:52 +0800 Subject: [PATCH] HBASE-21204 NPE when scan raw DELETE_FAMILY_VERSION and codec is not set Signed-off-by: tedyu --- .../src/main/protobuf/Cell.proto | 1 + hbase-protocol/src/main/protobuf/Cell.proto | 1 + .../client/TestScannersFromClientSide.java | 26 +++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/hbase-protocol-shaded/src/main/protobuf/Cell.proto b/hbase-protocol-shaded/src/main/protobuf/Cell.proto index 0e9eb94b5e8..aada35329aa 100644 --- a/hbase-protocol-shaded/src/main/protobuf/Cell.proto +++ b/hbase-protocol-shaded/src/main/protobuf/Cell.proto @@ -32,6 +32,7 @@ enum CellType { PUT = 4; DELETE = 8; + DELETE_FAMILY_VERSION = 10; DELETE_COLUMN = 12; DELETE_FAMILY = 14; diff --git a/hbase-protocol/src/main/protobuf/Cell.proto b/hbase-protocol/src/main/protobuf/Cell.proto index 2c6103540fb..e518e658f63 100644 --- a/hbase-protocol/src/main/protobuf/Cell.proto +++ b/hbase-protocol/src/main/protobuf/Cell.proto @@ -32,6 +32,7 @@ enum CellType { PUT = 4; DELETE = 8; + DELETE_FAMILY_VERSION = 10; DELETE_COLUMN = 12; DELETE_FAMILY = 14; 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 6803a2e0e25..5e8d107d4f5 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 @@ -17,6 +17,8 @@ */ 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.assertEquals; import static org.junit.Assert.assertFalse; @@ -608,6 +610,30 @@ public class TestScannersFromClientSide { "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 * on the same region server.