You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Niklas Matthies (Jira)" <ji...@apache.org> on 2022/11/08 16:24:00 UTC
[jira] [Created] (MNG-7594) ComparableVersion#getCanonical() returns incorrect results for zero between dashes
Niklas Matthies created MNG-7594:
------------------------------------
Summary: ComparableVersion#getCanonical() returns incorrect results for zero between dashes
Key: MNG-7594
URL: https://issues.apache.org/jira/browse/MNG-7594
Project: Maven
Issue Type: Bug
Components: Core
Affects Versions: 3.8.6
Reporter: Niklas Matthies
The {{getCanonical()}} method incorrectly reduces version strings like "1-0-1" to "1-1". This leads to contradictory results like in:
{{$ java -jar /path/to/maven-artifact-3.8.x.jar 1-0-1 1-1}}
{{1. 1-0-1 -> 1-1; tokens: [1, [[1]]]}}
{{ 1-0-1 < 1-1}}
{{2. 1-1 -> 1-1; tokens: [1, [1]]}}
Here 1. and 2. imply that both versions should be equal, but they still compare unequal (1-0-1 < 1-1). Arguably, the correct canonicalization for 1-0-1 here should be 1--1 (two dashes), since 1--1 compares equal to 1-0-1.
This is related to Bug 2 of MNG-6420, but could probably be fixed separately. I.e. just fix the broken canonicalization to make it consistent with {{compareTo()}}, but keep the comparison unchanged, without having to wait for a new spec to be written.
Note: This assumes that {{compareTo()}} is well-behaved for equality, i.e. defines a sound equivalence relation, which I think it does. It doesn't define a correct total order, as issues like MNG-6568 demonstrate, but that isn't relevant for making {{getCanonical()}} consistent with {{compareTo()}}.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)