Uploaded image for project: 'logback-audit'
  1. logback-audit
  2. LBAUDIT-2

Mismanagement of the map of permissions in the examples

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Trivial 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 = new ArrayList<Permission>(); }

      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 = new ArrayList<Permission>(); this.map.put(u.getName(), permissionList); }

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

      { permissionList.remove(p); }

      }

      Attachments

        Activity

          People

            logback-dev Logback dev list
            dez FERNANDEZ Ludovic
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: