Repository: hbase
Updated Branches:
  refs/heads/branch-2.1 7bed74293 -> 8339e4436


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/8339e443
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/8339e443
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/8339e443

Branch: refs/heads/branch-2.1
Commit: 8339e44361f3c33a6cb525bb2b25f13d2e0bf3f5
Parents: 7bed742
Author: xuqinya <[email protected]>
Authored: Tue Dec 18 08:19:47 2018 +0800
Committer: huzheng <[email protected]>
Committed: Tue Dec 18 16:40:26 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/8339e443/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 f6617a5..14c81a6 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
@@ -2494,7 +2494,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/8339e443/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 {

Reply via email to