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

This commit is contained in:
tedyu 2017-01-13 09:37:08 -08:00
parent 7794c530bd
commit cdee1a7034
2 changed files with 13 additions and 1 deletions

View File

@ -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) ||

View File

@ -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