Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-29773

stable sort order of AuthorizationMatrixProperty.java

XMLWordPrintable

      the jobconfighistory-plugin often reports diffs regarding the permission table but actually I have not changed anything in the permission table.

      If I compare the output I can see that all entries are there, but the order changed.
      So I actually get a diff where there is no one.

      I think there are two reasons for this:

      1. class AuthorizationMatrixProperty has two members which are of type
      HashHap and HashSet.
      They have no stable sort order, so when saving the order varies, which results in the diffs.
      Proposal: can we use the sorted variants of these two types (SortedMap, SortedSet) ?

      private final Map<Permission, Set<String>> grantedPermissions = new HashMap<Permission, Set<String>>();
      private Set<String> sids = new HashSet<String>();

      2. reason number two is that the configuration is saved at all,
      means I did not make a change, but a change it triggered.
      So I would propose to avoid saving changes when where are none, even if the user clicks on "Apply" or "Save" and in essence there are no changes. (e.g. deleted and added user again)
      Maybe this has to do with the stable sort order and is just a consequence of that.
      I do not know how a change is internally detected.

            mfriedenhagen Mirko Friedenhagen
            merkle Bernhard Merkle
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: