hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject hbase git commit: HBASE-17450 TablePermission#equals throws NPE after namespace support was added (huzheng)
Date Fri, 13 Jan 2017 17:39:11 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 49b5a6e80 -> ee66ab8e2


HBASE-17450 TablePermission#equals throws NPE after namespace support was added (huzheng)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/ee66ab8e
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/ee66ab8e
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/ee66ab8e

Branch: refs/heads/branch-1
Commit: ee66ab8e29f8593d7d823dc93fae12b06253dc06
Parents: 49b5a6e
Author: tedyu <yuzhihong@gmail.com>
Authored: Fri Jan 13 09:39:06 2017 -0800
Committer: tedyu <yuzhihong@gmail.com>
Committed: Fri Jan 13 09:39:06 2017 -0800

----------------------------------------------------------------------
 .../hadoop/hbase/security/access/TablePermission.java    |  3 ++-
 .../hbase/security/access/TestTablePermissions.java      | 11 +++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/ee66ab8e/hbase-client/src/main/java/org/apache/hadoop/hbase/security/access/TablePermission.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/security/access/TablePermission.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/security/access/TablePermission.java
index 481655a..3c75730 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/security/access/TablePermission.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/security/access/TablePermission.java
@@ -320,7 +320,8 @@ public class TablePermission extends Permission {
     }
     TablePermission other = (TablePermission)obj;
 
-    if (!(table.equals(other.getTableName()) &&
+    if (!(((table == null && other.getTableName() == null) ||
+           (table != null && table.equals(other.getTableName()))) &&
         ((family == null && other.getFamily() == null) ||
          Bytes.equals(family, other.getFamily())) &&
         ((qualifier == null && other.getQualifier() == null) ||

http://git-wip-us.apache.org/repos/asf/hbase/blob/ee66ab8e/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestTablePermissions.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestTablePermissions.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestTablePermissions.java
index 9b35ed1..84fa04d 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestTablePermissions.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestTablePermissions.java
@@ -84,6 +84,8 @@ public class TestTablePermissions {
     }
   };
 
+  private static String TEST_NAMESPACE = "perms_test_ns";
+  private static String TEST_NAMESPACE2 = "perms_test_ns2";
   private static TableName TEST_TABLE =
       TableName.valueOf("perms_test");
   private static TableName TEST_TABLE2 =
@@ -400,6 +402,15 @@ public class TestTablePermissions {
     p2 = new TablePermission(TEST_TABLE, null);
     assertFalse(p1.equals(p2));
     assertFalse(p2.equals(p1));
+
+    p1 = new TablePermission(TEST_NAMESPACE, TablePermission.Action.READ);
+    p2 = new TablePermission(TEST_NAMESPACE, TablePermission.Action.READ);
+    assertEquals(p1, p2);
+
+    p1 = new TablePermission(TEST_NAMESPACE, TablePermission.Action.READ);
+    p2 = new TablePermission(TEST_NAMESPACE2, TablePermission.Action.READ);
+    assertFalse(p1.equals(p2));
+    assertFalse(p2.equals(p1));
   }
 
   @Test


Mime
View raw message