You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Elliotte Rusty Harold (Jira)" <ji...@apache.org> on 2023/02/25 07:34:00 UTC

[jira] [Comment Edited] (MNG-7700) Improper canonicalization of versions

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

Elliotte Rusty Harold edited comment on MNG-7700 at 2/25/23 7:33 AM:
---------------------------------------------------------------------

To be specific, these unit tests both pass:

{{
    @Test
    public void testLeadingZeroes() {
        checkVersionsOrder("0.7", "2");
        checkVersionsOrder( "0.2", "1.0.7");
    }
    
    @Test
    public void testGetCanonical() {
    	// MNG-7700
    	newComparable("0.x");
    	newComparable("0-x");
    	newComparable("0.rc");
    	newComparable("0-1");
    	
    	ComparableVersion version = new ComparableVersion("0.x");
    	assertEquals("x", version.getCanonical());
    	ComparableVersion version2 = new ComparableVersion("0.2");
    	assertEquals("0.2", version2.getCanonical());
    }}}

If you have one that fails, let me know. 


was (Author: elharo):
To be specific, these unit tests both pass:

```
    @Test
    public void testLeadingZeroes() {
        checkVersionsOrder("0.7", "2");
        checkVersionsOrder( "0.2", "1.0.7");
    }
    
    @Test
    public void testGetCanonical() {
    	// MNG-7700
    	newComparable("0.x");
    	newComparable("0-x");
    	newComparable("0.rc");
    	newComparable("0-1");
    	
    	ComparableVersion version = new ComparableVersion("0.x");
    	assertEquals("x", version.getCanonical());
    	ComparableVersion version2 = new ComparableVersion("0.2");
    	assertEquals("0.2", version2.getCanonical());
    }
```

If you have one that fails, let me know. 

> Improper canonicalization of versions
> -------------------------------------
>
>                 Key: MNG-7700
>                 URL: https://issues.apache.org/jira/browse/MNG-7700
>             Project: Maven
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 3.8.7, 3.9.0
>            Reporter: David M. Lloyd
>            Assignee: Elliotte Rusty Harold
>            Priority: Major
>             Fix For: 3.8.x-candidate, 3.9.1-candidate, waiting-for-feedback
>
>
> The canonicalization logic for versions is incorrect.
> Using the method {{ComparableVersion#getCanonical}} as in {{new ComparableVersion(input).getCanonical()}}, the following results can be observed:
> ||Input||3.8.6 Output||3.8.6 OK?||3.9.0 Output||3.9.0 OK?||
> |{{1}}|{{1}}|yes|{{1}}|yes|
> |{{0.1}}|{{0.1}}|yes|{{0.1}}|yes|
> |{{0-1}}|{{1}}|no|{{1}}|no|
> |{{1.x}}|{{1.x}}|yes|{{1-x}}|maybe*|
> |{{1-x}}|{{1-x}}|yes|{{1-x}}|yes|
> |{{0.x}}|{{0.x}}|yes|{{x}}|no|
> |{{0-x}}|{{x}}|no|{{x}}|no|
> |{{x}}|{{x}}|yes|{{x}}|yes|
> |{{0.rc}}|{{0.rc}}|yes|{{rc}}|no|
> The "OK?" columns indicate whether parsing the canonical version string will yield a {{ComparableVersion}} instance that is {{equal}} to one constructed from the original input, i.e. it's internally consistent.
> The "maybe*" item indicates that starting with 3.9.0, version `1.x` is now considered to be equal to `1-x`. I'm not sure if this is a bug or not, or was intentional or not, but it is definitely a change.
> These canonicalizations seem to have gotten less consistent in the move to 3.9.0.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)