Details
-
Bug
-
Resolution: Unresolved
-
Trivial
-
None
-
0.5
-
None
Description
In PermissionMap classe, it write :
void addPermission(final User u, final Permission p) {
List<Permission> permissionList = this.map.get(u.getName());
if (permissionList == null)
permissionList.add(p);
}
This code cannot work:
if you want to add a new user, the user does not exist in the map, it is impossible to refer to a list of permission would be in the map because it has not been initialized.
The solution is :
void addPermission(final User u, final Permission p) {
List<Permission> permissionList = this.map.get(u.getName());
if (permissionList == null)
permissionList.add(p);
}
Otherwise it would be more correct to write the method "remove" like this:
void removePermission(final User u, final Permission p) {
final List<Permission> permissionList = this.map.get(u.getName());
if (permissionList != null && !permissionList.isEmpty())
}