cstamas commented on issue #2366:
URL: 
https://github.com/apache/maven-resolver/issues/2366#issuecomment-7242597163

   I don't think this is a race, and `BasicRepositoryConnector.get` does not 
stop at the first failure. Each transfer's exception is caught in 
`TaskRunner.run()` and stored on that transfer, and `errorForwarder.await()` 
waits for all tasks to finish. In any case, a connector only ever talks to one 
remote repository.
   
   What I think actually happens:
   
   1. **Metadata is resolved for each repository separately, and in parallel** 
(`DefaultMetadataResolver`, one `ResolveTask` per repository). That's why the 
log shows three metadata requests at the same time, and why `1.7.0` is found in 
`central`.
   2. **Artifacts are resolved one repository group at a time.** Repositories 
are put into the same `ResolutionGroup` when their URL, content type and 
repository-manager flag match. The repository ID is ignored:
      
https://github.com/apache/maven-resolver/blob/54aa1d621c87912482b56c43222e93aaa6535124/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultArtifactResolver.java#L767-L771
      `sonatype-central-portal` and `central` both have the URL 
`https://repo.maven.apache.org/maven2`. So `central` is folded into the group 
of `sonatype-central-portal`, which comes first in the list, and that group 
downloads through `sonatype-central-portal`.
   3. Njord takes over `sonatype-central-portal` and serves it from its local 
store (`file:///…/.njord/aem-dictionary-translator-00002`). The jar is not in 
that store, so it's "not found". **`central` is never contacted for the jar**, 
which matches the log: there is no "Downloading from central" line for the 
`.jar`.
   4. The next group is `nexus-netcentric`, which fails with 
`UnknownHostException`. The artifact ends up missing, and `BaselineMojo` 
swallows the `RepositoryException` and reports "Unable to locate a previous 
version of the artifact".
   
   So this is an interaction between the resolver's grouping by URL and Njord. 
The grouping assumes that the same URL means the same content. Njord breaks 
that assumption by redirecting by repository ID while the URL stays the same. 
Without Njord, the merged group would fetch from the real Central and succeed.
   
   To confirm: run the same build without Njord, or remove the duplicate 
`sonatype-central-portal` entry from the repository list. The jar should then 
resolve from `central`.
   
   Possible fixes:
   - Njord rewrites the URL of the repository it redirects, so it no longer 
matches `central`; or
   - `ResolutionGroup.matches()` also compares repository IDs, but that loses 
the dedupe this grouping exists for.
   


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