[ https://issues.apache.org/jira/browse/MNG-6420?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17006447#comment-17006447 ]
Elliotte Rusty Harold commented on MNG-6420: -------------------------------------------- Per spec, I think "2.0" == "2.0.0.0". If the test says otherwise, the test is wrong and should be fixed. "2.0.0.0" < "2.0.a.0" < "2.0.0.a" is a tougher case. I think what should be true is that 2.0.0 > 2.0.0.a because alpha less then release, but I'm not sure what the spec says or why. Don't concern yourself with performance. Knuth's law applies. I don't know if we use any immutable collections or not. If they're internal, it shouldn't matter a great deal. If they're exposed in the public API, I prefer to avoid immutable java.util.List, java.util.Set, etc. UnsupportedOperationException is a mistake, and the design of the Java collections API has been broken since Java 1.1, but we can't fix that here. We can't change the public API in this release, so ComparableVersion#parseVersion can't be removed until at least 4.0. I agree it wasn't well thought out. We could deprecate it now, but if you want to do that please file a separate issue and a different PR for that. > ComparableVersion incorrectly parses certain version strings > ------------------------------------------------------------ > > Key: MNG-6420 > URL: https://issues.apache.org/jira/browse/MNG-6420 > Project: Maven > Issue Type: Bug > Components: core > Affects Versions: 3.5.3 > Reporter: Ross Goldberg > Priority: Major > Fix For: wontfix-candidate > > > For certain version strings, ComparableVersion doesn't follow the Maven > version order spec > (https://maven.apache.org/pom.html#Version_Order_Specification). > To improve the code & fix the following bugs, I completely rewrote the > version parser (using Java 10 & Google Guava 25.1). It is attached & passes > all of the tests from ComparableVersionTest. > Bug 1: > > java -jar /usr/local/Cellar/maven/3.5.3/libexec/lib/maven-artifact-3.5.3.jar > 1-0.3 1 > > Outputs: > > 1. 1-0.3 == 1-0.3 > 1-0.3 == 1 > 2. 1 == 1 > > This probleem stems from: > > [https://github.com/apache/maven/blob/b8c06e61ab73cd9e25a5b2c93d9e5077b2196751/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/ComparableVersion.java#L295-L296] > > > > Bug 2: > > java -jar /usr/local/Cellar/maven/3.5.3/libexec/lib/maven-artifact-3.5.3.jar > 1-0-2 1-0.1 > > 1. 1-0-2 == 1-2 > 1-0-2 < 1-0.1 > 2. 1-0.1 == 1-0.1 > > This problem stems from retaining ListItems that, after normalization, have > no children other than the subsequent ListItem. Removing the unnecessary > ListItem should fix this (i.e. remove the extraneous ListItem (named > extraneous) from its parent ListItem (named parent), then add the only child > of extraneous to parent). -- This message was sent by Atlassian Jira (v8.3.4#803005)