From af6a84cdc2d0b1ab912aae34ef0f9d3aabf5c4fe Mon Sep 17 00:00:00 2001 From: jingyuntian Date: Tue, 18 Sep 2018 12:02:37 +0800 Subject: [PATCH] NPE when scan raw DELETE_FAMILY_VERSION and codec is not set --- hbase-protocol-shaded/src/main/protobuf/Cell.proto | 1 + hbase-protocol/src/main/protobuf/Cell.proto | 1 + .../hbase/client/TestScannersFromClientSide.java | 25 ++++++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/hbase-protocol-shaded/src/main/protobuf/Cell.proto b/hbase-protocol-shaded/src/main/protobuf/Cell.proto index 0e9eb94..aada353 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 2c61035..e518e65 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 6803a2e..133fd9a 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,29 @@ 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. -- 2.7.4