Uploaded image for project: 'jclouds'
  1. jclouds
  2. JCLOUDS-1237

IpPermission#compareTo is inconsistent with equals

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.0
    • Fix Version/s: 2.1.0, 2.0.1
    • Component/s: jclouds-compute
    • Labels:
      None

      Description

      org.jclouds.net.domain.IpPermission#compareTo is inconsistent with its definition of equals. compareTo only compares protocols whereas equals compares all fields in the class. The class does not behave in sorted sets.

      From Comparable's documentation:

      It is strongly recommended (though not required) that natural orderings be consistent with equals. This is so because sorted sets (and sorted maps) without explicit comparators behave "strangely" when they are used with elements (or keys) whose natural ordering is inconsistent with equals. In particular, such a sorted set (or sorted map) violates the general contract for set (or map), which is defined in terms of the equals method.

      For example, if one adds two keys a and b such that (!a.equals(b) && a.compareTo(b) == 0) to a sorted set that does not use an explicit comparator, the second add operation returns false (and the size of the sorted set does not increase) because a and b are equivalent from the sorted set's perspective.

        Activity

        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit e294de025ed7d3df7ebfb65ce05979f363869371 in jclouds's branch refs/heads/2.0.x from Geoff Macartney
        [ https://git-wip-us.apache.org/repos/asf?p=jclouds.git;h=e294de0 ]

        JCLOUDS-1237: Add compareTo() for IpPermission.

        Show
        jira-bot ASF subversion and git services added a comment - Commit e294de025ed7d3df7ebfb65ce05979f363869371 in jclouds's branch refs/heads/2.0.x from Geoff Macartney [ https://git-wip-us.apache.org/repos/asf?p=jclouds.git;h=e294de0 ] JCLOUDS-1237 : Add compareTo() for IpPermission.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit b8fd47ba8d0086f3b1b15f43360a1f4c4dd9eff0 in jclouds's branch refs/heads/master from Geoff Macartney
        [ https://git-wip-us.apache.org/repos/asf?p=jclouds.git;h=b8fd47b ]

        JCLOUDS-1237: Add compareTo() for IpPermission.

        Show
        jira-bot ASF subversion and git services added a comment - Commit b8fd47ba8d0086f3b1b15f43360a1f4c4dd9eff0 in jclouds's branch refs/heads/master from Geoff Macartney [ https://git-wip-us.apache.org/repos/asf?p=jclouds.git;h=b8fd47b ] JCLOUDS-1237 : Add compareTo() for IpPermission.
        Hide
        geomacy Geoff Macartney added a comment -

        I've PRed https://github.com/jclouds/jclouds/pull/1064 as a candidate fix for this.

        Show
        geomacy Geoff Macartney added a comment - I've PRed https://github.com/jclouds/jclouds/pull/1064 as a candidate fix for this.

          People

          • Assignee:
            Unassigned
            Reporter:
            sjcorbett Sam Corbett
          • Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development