You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Jason Brown (JIRA)" <ji...@apache.org> on 2016/02/23 15:38:18 UTC

[jira] [Commented] (CASSANDRA-11216) Range.compareTo() violates the contract of Comparable

    [ https://issues.apache.org/jira/browse/CASSANDRA-11216?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15158970#comment-15158970 ] 

Jason Brown commented on CASSANDRA-11216:
-----------------------------------------

|| 2.2 || 3.0 || trunk ||
|[branch|https://github.com/apache/cassandra/compare/trunk...jasobrown:range_compareTo_2.2]|[branch|https://github.com/apache/cassandra/compare/trunk...jasobrown:range_compareTo_3.0]|[branch|https://github.com/apache/cassandra/compare/trunk...jasobrown:range_compareTo_3.x]
|[testall|http://cassci.datastax.com/view/Dev/view/jasobrown/job/jasobrown-range_compareTo_2.2-testall]|[testall|http://cassci.datastax.com/view/Dev/view/jasobrown/job/jasobrown-range_compareTo_3.0-testall]|[testall|http://cassci.datastax.com/view/Dev/view/jasobrown/job/jasobrown-range_compareTo_3.x-testall]
|[dtest|http://cassci.datastax.com/view/Dev/view/jasobrown/job/jasobrown-range_compareTo_2.2-dtest]|[dtest|http://cassci.datastax.com/view/Dev/view/jasobrown/job/jasobrown-range_compareTo_3.0-dtest]|[dtest|http://cassci.datastax.com/view/Dev/view/jasobrown/job/jasobrown-range_compareTo_3.x-dtest]

> Range.compareTo() violates the contract of Comparable
> -----------------------------------------------------
>
>                 Key: CASSANDRA-11216
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-11216
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Core
>            Reporter: Jason Brown
>            Assignee: Jason Brown
>            Priority: Minor
>
> 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.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)