You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2022/10/12 07:12:00 UTC

[GitHub] [maven] kwin opened a new pull request, #823: [MNG-7561] never resolve version ranges with same lower and upper bound

kwin opened a new pull request, #823:
URL: https://github.com/apache/maven/pull/823

   Following this checklist to help us incorporate your
   contribution quickly and easily:
   
    - [x] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/MNG) 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.
    - [x] Each commit in the pull request should have a meaningful subject line and body.
    - [x] 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.
    - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
    - [x] Run `mvn clean verify` to make sure basic checks pass. A more thorough check will
          be performed on your pull request automatically.
    - [x] You have run the [Core IT][core-its] successfully.
   
   If your pull request is about ~20 lines of code you don't need to sign an
   [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf) 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](http://www.apache.org/licenses/LICENSE-2.0)
   you have to acknowledge this by using the following check-box.
   
    - [ ] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   
    - [x] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   [core-its]: https://maven.apache.org/core-its/core-it-suite/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] cstamas commented on pull request #823: [MNG-7561] never resolve version ranges with same lower and upper bound

Posted by GitBox <gi...@apache.org>.
cstamas commented on PR #823:
URL: https://github.com/apache/maven/pull/823#issuecomment-1291012549

   > 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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] gnodet commented on pull request #823: [MNG-7561] never resolve version ranges with same lower and upper bound

Posted by GitBox <gi...@apache.org>.
gnodet commented on PR #823:
URL: https://github.com/apache/maven/pull/823#issuecomment-1291033395

   The test fails with an NPE on the modified line:
   ```
   result.addVersion( versionConstraint.getRange().getLowerBound().getVersion() );
   ```
   so that means `getLowerBound()` returns null (as `getRange()` has been tested before).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] kwin commented on a diff in pull request #823: [MNG-7561] never resolve version ranges with same lower and upper bound

Posted by GitBox <gi...@apache.org>.
kwin commented on code in PR #823:
URL: https://github.com/apache/maven/pull/823#discussion_r993263931


##########
maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java:
##########
@@ -111,28 +111,36 @@ public VersionRangeResult resolveVersionRange( RepositorySystemSession session,
         }
         else
         {
-            Map<String, ArtifactRepository> versionIndex = getVersions( session, result, request );
-
-            List<Version> versions = new ArrayList<>();
-            for ( Map.Entry<String, ArtifactRepository> v : versionIndex.entrySet() )
+            if ( Objects.equals( versionConstraint.getRange().getLowerBound(), 
+                                 versionConstraint.getRange().getUpperBound() ) )
+            {
+                result.addVersion( versionConstraint.getRange().getLowerBound().getVersion() );

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



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] kwin merged pull request #823: [MNG-7561] never resolve version ranges with same lower and upper bound

Posted by GitBox <gi...@apache.org>.
kwin merged PR #823:
URL: https://github.com/apache/maven/pull/823


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] gnodet commented on pull request #823: [MNG-7561] never resolve version ranges with same lower and upper bound

Posted by GitBox <gi...@apache.org>.
gnodet commented on PR #823:
URL: https://github.com/apache/maven/pull/823#issuecomment-1277663290

   > > 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.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] gnodet commented on pull request #823: [MNG-7561] never resolve version ranges with same lower and upper bound

Posted by GitBox <gi...@apache.org>.
gnodet commented on PR #823:
URL: https://github.com/apache/maven/pull/823#issuecomment-1277775716

   @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 range version belongs to the range enforced in case of a dependency conflict ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] gnodet commented on a diff in pull request #823: [MNG-7561] never resolve version ranges with same lower and upper bound

Posted by GitBox <gi...@apache.org>.
gnodet commented on code in PR #823:
URL: https://github.com/apache/maven/pull/823#discussion_r994684855


##########
maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java:
##########
@@ -111,28 +111,36 @@ public VersionRangeResult resolveVersionRange( RepositorySystemSession session,
         }
         else
         {
-            Map<String, ArtifactRepository> versionIndex = getVersions( session, result, request );
-
-            List<Version> versions = new ArrayList<>();
-            for ( Map.Entry<String, ArtifactRepository> v : versionIndex.entrySet() )
+            if ( Objects.equals( versionConstraint.getRange().getLowerBound(), 
+                                 versionConstraint.getRange().getUpperBound() ) )
+            {
+                result.addVersion( versionConstraint.getRange().getLowerBound().getVersion() );

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



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] cstamas commented on pull request #823: [MNG-7561] never resolve version ranges with same lower and upper bound

Posted by GitBox <gi...@apache.org>.
cstamas commented on PR #823:
URL: https://github.com/apache/maven/pull/823#issuecomment-1275912140

   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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] cstamas commented on pull request #823: [MNG-7561] never resolve version ranges with same lower and upper bound

Posted by GitBox <gi...@apache.org>.
cstamas commented on PR #823:
URL: https://github.com/apache/maven/pull/823#issuecomment-1291019905

   Hm, it fails due NPE?
   
   ```
   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)
   ...
   ```
   
   ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] kwin commented on pull request #823: [MNG-7561] never resolve version ranges with same lower and upper bound

Posted by GitBox <gi...@apache.org>.
kwin commented on PR #823:
URL: https://github.com/apache/maven/pull/823#issuecomment-1291015570

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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] kwin commented on a diff in pull request #823: [MNG-7561] never resolve version ranges with same lower and upper bound

Posted by GitBox <gi...@apache.org>.
kwin commented on code in PR #823:
URL: https://github.com/apache/maven/pull/823#discussion_r993263931


##########
maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java:
##########
@@ -111,28 +111,36 @@ public VersionRangeResult resolveVersionRange( RepositorySystemSession session,
         }
         else
         {
-            Map<String, ArtifactRepository> versionIndex = getVersions( session, result, request );
-
-            List<Version> versions = new ArrayList<>();
-            for ( Map.Entry<String, ArtifactRepository> v : versionIndex.entrySet() )
+            if ( Objects.equals( versionConstraint.getRange().getLowerBound(), 
+                                 versionConstraint.getRange().getUpperBound() ) )
+            {
+                result.addVersion( versionConstraint.getRange().getLowerBound().getVersion() );

Review Comment:
   why is this shortcut allowed for recommended versions (soft-references)?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] michael-o commented on pull request #823: [MNG-7561] never resolve version ranges with same lower and upper bound

Posted by GitBox <gi...@apache.org>.
michael-o commented on PR #823:
URL: https://github.com/apache/maven/pull/823#issuecomment-1277446298

   > 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.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org