You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Konrad Windszus (Jira)" <ji...@apache.org> on 2022/12/09 15:37:00 UTC
[jira] [Comment Edited] (MRESOLVER-306) Make GenericVersionScheme.parseVersionConstraint(...) throw exception when comma-separated version string not starting with "(" or "[" is passed
[ https://issues.apache.org/jira/browse/MRESOLVER-306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17645347#comment-17645347 ]
Konrad Windszus edited comment on MRESOLVER-306 at 12/9/22 3:36 PM:
--------------------------------------------------------------------
It turned out that the ordering imposed by both {{org.apache.maven.artifact.versioning.DefaultArtifactVersion}} and {{org.eclipse.aether.util.version.GenericVersion}} is the same, i.e.
# Version("1,2,3") < Version("2")
# Version("1,2,3") < Version("4")
# Version("1,2,3") < Version("1.0.1")
# Version("1,2,3") > Version("1")
Both treat the the version ("1,2,3") as version containing out of 5 individual parts:
# number 1
# string ","
# number 2
# string ","
# number 3
and compare each part individually. Therefore although "1,2,3" is probably not what was intended is is a perfectly valid version constraint consisting out of a single (unusual) version string and therefore must not be rejected.
was (Author: kwin):
It turned out that the ordering imposed by both {{org.apache.maven.artifact.versioning.DefaultArtifactVersion}} and {{org.eclipse.aether.util.version.GenericVersion}} is the same, i.e.
# Version("1,2,3") < Version("2")
# Version("1,2,3") < Version("4")
# Version("1,2,3") < Version("1.0.1")
# Version("1,2,3") > Version("1")
Both treat the the version ("1,2,3") as version containing out of 5 individual parts:
# number 1
# string ","
# number 2
# string ","
# number 3
and compare each part individually. Therefore although "1,2,3" is probably not what was intended is is a perfectly valid version constraint consisting out of a single (unusual) version string.
> Make GenericVersionScheme.parseVersionConstraint(...) throw exception when comma-separated version string not starting with "(" or "[" is passed
> ------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: MRESOLVER-306
> URL: https://issues.apache.org/jira/browse/MRESOLVER-306
> Project: Maven Resolver
> Issue Type: Improvement
> Components: Resolver
> Reporter: Konrad Windszus
> Priority: Major
>
> Currently when {{GenericVersionScheme.parseVersionConstraint("1,2,3")}} is called an unexpected Object is returned which returns {{false}} for every version passed to {{VersionConstraint.containsVersion}} and also returns other values for {{VersionConstraint.getVersion().compareTo(some other version)}} than {{o.a.m.artifact.versioning.VersionRange.getRecommendedVersion().compareTo(some other version)}} (https://github.com/apache/maven/blob/55431cd267af1f4131f6fcb4c3b0d9c2c49641bf/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/DefaultArtifactVersion.java#L65)
> Instead passing such invalid string should lead to an {{InvalidVersionSpecificationException}}.
> For a real-life example of such invalid version ranges refer to https://github.com/mybatis/parent/issues/401.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)