Repository: hbase Updated Branches: refs/heads/branch-2.0 0ed55141b -> 4a958c8c4
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/4a958c8c Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/4a958c8c Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/4a958c8c Branch: refs/heads/branch-2.0 Commit: 4a958c8c49d40676b16989b1078e352ac14703ad Parents: 0ed5514 Author: xuqinya <[email protected]> Authored: Tue Dec 18 08:19:47 2018 +0800 Committer: huzheng <[email protected]> Committed: Tue Dec 18 16:50:25 2018 +0800 ---------------------------------------------------------------------- .../hadoop/hbase/regionserver/RSRpcServices.java | 3 ++- .../hadoop/hbase/quotas/TestQuotaThrottle.java | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/4a958c8c/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 e4623c1..4761e4d 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 @@ -2480,7 +2480,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/4a958c8c/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 59ba322..8086d94 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 @@ -509,6 +509,23 @@ public class TestQuotaThrottle { assertEquals(30, doGets(30, tables[1])); } + @Test + public void testTableExistsGetThrottle() throws Exception { + final Admin admin = TEST_UTIL.getAdmin(); + + // 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 Table... tables) throws Exception { int count = 0; try {
