Repository: hbase
Updated Branches:
  refs/heads/branch-2 ee214cbe4 -> 99de534cc


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

Branch: refs/heads/branch-2
Commit: 99de534cc4670661e3dc7714e35e0e41d94f3586
Parents: ee214cb
Author: xuqinya <[email protected]>
Authored: Tue Dec 18 08:19:47 2018 +0800
Committer: huzheng <[email protected]>
Committed: Tue Dec 18 16:51:46 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/99de534c/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 d8967c4..fce3ac4 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
@@ -2519,7 +2519,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/99de534c/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 e506a08..c069403 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
@@ -553,6 +553,23 @@ public class TestQuotaThrottle {
     triggerTableCacheRefresh(true, TABLE_NAMES[0]);
   }
 
+  @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 {
     return doPuts(maxOps, -1, tables);
   }

Reply via email to