Skip to content

[MNG-7561] never resolve version ranges with same lower and upper bound#823

Merged
kwin merged 1 commit intomasterfrom
bugfix/mng-7561-version-ranges-with-same-lower-and-upper-bound
Nov 7, 2022
Merged

[MNG-7561] never resolve version ranges with same lower and upper bound#823
kwin merged 1 commit intomasterfrom
bugfix/mng-7561-version-ranges-with-same-lower-and-upper-bound

Conversation

@kwin
Copy link
Copy Markdown
Member

@kwin kwin commented Oct 12, 2022

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Make sure there is a JIRA issue filed
    for the change (usually before you start working on it). Trivial changes like typos do not
    require a JIRA issue. Your pull request should address just this issue, without
    pulling in other changes.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [MNG-XXX] SUMMARY, where you replace MNG-XXX
    and SUMMARY with the appropriate JIRA issue. Best practice is to use the JIRA issue
    title in the pull request title and in the first line of the commit message.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean verify to make sure basic checks pass. A more thorough check will
    be performed on your pull request automatically.
  • You have run the Core IT successfully.

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

@kwin kwin requested review from cstamas and michael-o October 12, 2022 07:12
@kwin kwin force-pushed the bugfix/mng-7561-version-ranges-with-same-lower-and-upper-bound branch 2 times, most recently from 61e6d23 to 6475b24 Compare October 12, 2022 07:27
@cstamas
Copy link
Copy Markdown
Member

cstamas commented Oct 12, 2022

if ( Objects.equals( versionConstraint.getRange().getLowerBound(),
versionConstraint.getRange().getUpperBound() ) )
{
result.addVersion( versionConstraint.getRange().getLowerBound().getVersion() );
Copy link
Copy Markdown
Member Author

@kwin kwin Oct 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this shortcut allowed for recommended versions (soft-requirements)?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the artifact does not exist with the given version ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as for soft-requirements, i.e. that would lead to an exception subsequently.

@michael-o
Copy link
Copy Markdown
Member

@gnodet
Copy link
Copy Markdown
Contributor

gnodet commented Oct 13, 2022

IMHO this PR is wrong, as commented on issue https://issues.apache.org/jira/browse/MNG-7561?focusedCommentId=17616329&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-17616329

I follow this reasoning.

Agreed, but then I agree with @kwin that it also seems incorrect that for a non range version, no check is performed. I don't really see why the use case would really differ.

@gnodet
Copy link
Copy Markdown
Contributor

gnodet commented Oct 13, 2022

@michael-o @cstamas I'm trying to understand how this works. If the VersionResolver returns a Set<String> for versions when given a range, and a single version when given a soft version, where is the fact that the selected version belongs to the enforced range in case of a dependency conflict ?

@michael-o michael-o removed their request for review October 20, 2022 21:28
@cstamas
Copy link
Copy Markdown
Member

cstamas commented Oct 25, 2022

IMHO this PR is wrong, as commented on issue https://issues.apache.org/jira/browse/MNG-7561?focusedCommentId=17616329&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-17616329

I change my mind here, I believe I am wrong: VersionResolver is NOT ensuring that version exists, it simply uses metadata to "discover" available versions instead, so I change my mind: the PR seems ok

@kwin
Copy link
Copy Markdown
Member Author

kwin commented Oct 25, 2022

Some ITs fail with this PR as those also assume same upper/lower bound ranges should be resolved. Are those wrong?

@gnodet gnodet self-requested a review October 25, 2022 19:08
@cstamas
Copy link
Copy Markdown
Member

cstamas commented Oct 25, 2022

Hm, it fails due NPE?

Errors: 
Error:    MavenITmng0505VersionRangeTest.testitMNG505:66

....
java.lang.NullPointerException
    at org.apache.maven.repository.internal.DefaultVersionRangeResolver.resolveVersionRange (DefaultVersionRangeResolver.java:117)
    at org.eclipse.aether.internal.impl.collect.DependencyCollectorDelegate.cachedResolveRangeResult (DependencyCollectorDelegate.java:438)
...

?

@gnodet
Copy link
Copy Markdown
Contributor

gnodet commented Oct 25, 2022

The test fails with an NPE on the modified line:

result.addVersion( versionConstraint.getRange().getLowerBound().getVersion() );

Given the earlier tests, it means versionConstraint.getRange().getLowerBound() == null and versionConstraint.getRange().getUpperBound() == null, so something like (,), not sure it's even valid...

Or does that happen so that the maven-resolver can obtain a list of existing versions for a given artifact, if none is provided, as done for plugin resolution ?

Co-authored-by: Guillaume Nodet <gnodet@gmail.com>
@kwin kwin force-pushed the bugfix/mng-7561-version-ranges-with-same-lower-and-upper-bound branch from 60edb5b to d87710f Compare November 7, 2022 13:12
@kwin kwin merged commit 431e2b3 into master Nov 7, 2022
@kwin kwin deleted the bugfix/mng-7561-version-ranges-with-same-lower-and-upper-bound branch November 7, 2022 16:04
@jira-importer
Copy link
Copy Markdown

Resolve #8890

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants