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

IpPermission#compareTo is inconsistent with equals

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.0.0
    • 2.1.0, 2.0.1
    • jclouds-compute
    • 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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            sjcorbett Samuel James Corbett
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: