From 085c45f38b5f0ba106d12a22413f65112562f998 Mon Sep 17 00:00:00 2001 From: jingyuntian Date: Tue, 18 Sep 2018 10:51:49 +0800 Subject: [PATCH] NPE when scan raw DELETE_FAMILY_VERSION and codec is not set --- .../apache/hadoop/hbase/ipc/AbstractRpcClient.java | 1 + hbase-protocol-shaded/src/main/protobuf/Cell.proto | 1 + hbase-protocol/src/main/protobuf/Cell.proto | 1 + .../hbase/client/TestScannersFromClientSide.java | 23 ++++++++++++++++++++++ 4 files changed, 26 insertions(+) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/AbstractRpcClient.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/AbstractRpcClient.java index c8904f4..a75924a 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/AbstractRpcClient.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/AbstractRpcClient.java @@ -236,6 +236,7 @@ public abstract class AbstractRpcClient implements RpcC * @return Codec to use on this client. */ Codec getCodec() { + LOG.info("tjy: {}, {}",conf.get(HConstants.RPC_CODEC_CONF_KEY), conf.get(DEFAULT_CODEC_CLASS)); // For NO CODEC, "hbase.client.rpc.codec" must be configured with empty string AND // "hbase.client.default.rpc.codec" also -- because default is to do cell block encoding. String className = conf.get(HConstants.RPC_CODEC_CONF_KEY, getDefaultCodec(this.conf)); 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..7a4530a 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,27 @@ 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); + } + } + /** * Test from client side for scan while the region is reopened * on the same region server. -- 2.7.4