Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-11216

Range.compareTo() violates the contract of Comparable

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Low
    • Resolution: Fixed
    • Fix Version/s: 2.2.6, 3.0.4, 3.4
    • Component/s: Legacy/Core
    • Labels:
      None
    • Severity:
      Low

      Description

      When running some quick-check style tests, I discovered that if both of the ranges being compared wrap around, then the result of the comparison depends on which range is evaluated first. For example, two ranges:

      A =

      { -1, 2 }

      B =

      { -2, 1 }

      and then compare them together:
      A.compareTo(B) == -1
      B.compareTo(A) == -1

      This is because the logic of the existing Range.compareTo() simply checks to see if the this range wraps around, and returns -1. This bug does not appear to affect c* until 3.0, and then only in one place (MerkleTrees.TokenRangeComparator#compare) that I could identify.

        Attachments

          Activity

            People

            • Assignee:
              jasobrown Jason Brown
              Reporter:
              jasobrown Jason Brown
              Authors:
              Jason Brown
              Reviewers:
              Branimir Lambov
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: