Fix NullPointerException when comparing AccessSections

AccessSection.permissions and Permission.rules may not be set and null
values should be handled in the equals methods.

We saw this NPE when PermissionCollection tried to sort the access
sections.

Change-Id: I6f5a0886e6f9e5498fe9d756f289c5e91ed3485e
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
(cherry picked from commit 915104def3)
This commit is contained in:
Edwin Kempin 2013-06-18 10:11:41 +02:00 committed by David Pursehouse
parent ff4c66885d
commit 121cbead32
2 changed files with 4 additions and 4 deletions

View File

@ -124,7 +124,7 @@ public class AccessSection extends RefConfigSection implements
if (!super.equals(obj) || !(obj instanceof AccessSection)) {
return false;
}
return new HashSet<Permission>(permissions).equals(new HashSet<Permission>(
((AccessSection) obj).permissions));
return new HashSet<Permission>(getPermissions()).equals(new HashSet<Permission>(
((AccessSection) obj).getPermissions()));
}
}

View File

@ -241,8 +241,8 @@ public class Permission implements Comparable<Permission> {
if (!name.equals(other.name) || exclusiveGroup != other.exclusiveGroup) {
return false;
}
return new HashSet<PermissionRule>(rules)
.equals(new HashSet<PermissionRule>(other.rules));
return new HashSet<PermissionRule>(getRules())
.equals(new HashSet<PermissionRule>(other.getRules()));
}
@Override