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:37:11 GMT
Repository: hbase
Updated Branches:
  refs/heads/master 7794c530b -> cdee1a703


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

Branch: refs/heads/master
Commit: cdee1a7034a5ec39a0d5435916050c3ae0ffa339
Parents: 7794c53
Author: tedyu <yuzhihong@gmail.com>
Authored: Fri Jan 13 09:37:08 2017 -0800
Committer: tedyu <yuzhihong@gmail.com>
Committed: Fri Jan 13 09:37:08 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/cdee1a70/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 e0d3424..cf3f071 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
@@ -314,7 +314,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/cdee1a70/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 380c252..1e525e2 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
@@ -83,6 +83,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 =
@@ -409,6 +411,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