Repository: hbase Updated Branches: refs/heads/branch-1 049307c9a -> bbf17e614
HBASE-21592 quota.addGetResult(r) throw NPE Signed-off-by: huzheng <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/bbf17e61 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/bbf17e61 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/bbf17e61 Branch: refs/heads/branch-1 Commit: bbf17e6149e7ea511f0e5bbaa038cf5402fd9431 Parents: 049307c Author: xuqinya <[email protected]> Authored: Tue Dec 18 08:41:04 2018 +0800 Committer: huzheng <[email protected]> Committed: Tue Dec 18 18:56:22 2018 +0800 ---------------------------------------------------------------------- .../hadoop/hbase/regionserver/RSRpcServices.java | 3 ++- .../hadoop/hbase/quotas/TestQuotaThrottle.java | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/bbf17e61/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java index 8b36b90..4dd8061 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java @@ -2322,7 +2322,8 @@ public class RSRpcServices implements HBaseRPCErrorHandler, } builder.setResult(pbr); } - if (r != null) { + //r.cells is null when an table.exists(get) call + if (r != null && r.rawCells() != null) { quota.addGetResult(r); } return builder.build(); http://git-wip-us.apache.org/repos/asf/hbase/blob/bbf17e61/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaThrottle.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaThrottle.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaThrottle.java index e0defa2..a5bdd1c 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaThrottle.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaThrottle.java @@ -25,6 +25,7 @@ import org.apache.hadoop.hbase.client.Get; import org.apache.hadoop.hbase.client.HTable; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException; +import org.apache.hadoop.hbase.client.Table; import org.apache.hadoop.hbase.security.User; import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.util.Bytes; @@ -486,6 +487,23 @@ public class TestQuotaThrottle { assertEquals(30, doGets(30, tables[1])); } + @Test + public void testTableExistsGetThrottle() throws Exception { + final Admin admin = TEST_UTIL.getHBaseAdmin(); + + // Add throttle quota + admin.setQuota(QuotaSettingsFactory.throttleTable(TABLE_NAMES[0], + ThrottleType.REQUEST_NUMBER, 100, TimeUnit.MINUTES)); + triggerTableCacheRefresh(false, TABLE_NAMES[0]); + + Table table = TEST_UTIL.getConnection().getTable(TABLE_NAMES[0]); + // An exists call when having throttle quota + table.exists(new Get(Bytes.toBytes("abc"))); + + admin.setQuota(QuotaSettingsFactory.unthrottleTable(TABLE_NAMES[0])); + triggerTableCacheRefresh(true, TABLE_NAMES[0]); + } + private int doPuts(int maxOps, final HTable... tables) throws Exception { int count = 0; try {
