arturobernalg opened a new pull request, #2209:
URL: https://github.com/apache/maven-resolver/pull/2209

   ## What and why
   
   `DefaultArtifactResolver` accepts a `VersionResult` whose version is null or 
blank, which happens whenever the request's `Artifact` has no version at all 
(#1269 / MRESOLVER-597). It keeps going, and the failure only surfaces much 
later as an opaque `IllegalArgumentException` thrown by 
`DefaultLocalPathComposer` about an invalid relative path, for instance 
`com/example/no-such-artifact//no-such-artifact-.jar`, with no mention of the 
real cause.
   
   I reproduced this against the current `maven-resolver-impl` code, both as a 
unit test and as a standalone program using `maven-resolver-supplier-mvn3`: 
resolving `com.example:no-such-artifact:jar` with no version throws that 
unrelated path exception.
   
   The issue suggested either documenting the exception or failing fast when 
the request is built. Failing fast at construction time is not possible in 
general, because the input version can be a symbolic one (`RELEASE`, `LATEST`, 
a range) that only the version resolver can turn into a concrete version, so 
the earliest point where an empty result is known is right after 
`versionResolver.resolveVersion` returns.
   
   ## How
   
   `DefaultArtifactResolver#resolve` now rejects a null or blank resolved 
version immediately after it is applied to the artifact, with an 
`ArtifactNotFoundException` that names the artifact and says its version is 
missing or blank, instead of letting execution reach the local repository path 
composer.
   
   ## Tests
   
   
`DefaultArtifactResolverTest#testResolveArtifactWithBlankVersionFailsWithClearMessage`
 fails without the change (the stub local repository manager used in this test 
class does not reproduce the production `IllegalArgumentException`, but the 
assertion on the clear message fails, confirming no such message was produced 
before). With the change, this test and the rest of `maven-resolver-impl` pass 
(589 tests), and `checkstyle:check` is clean.
   
   ---
   
   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)
   check one of the following:
   
   - [x] I hereby declare this contribution to be licensed under the [Apache 
License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0)
   - [x] I hereby declare that I have filed an [Apache Individual Contributor 
License Agreement](https://www.apache.org/licenses/icla.pdf).
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to