Ayush0612005 commented on PR #284:
URL: 
https://github.com/apache/maven-artifact-plugin/pull/284#issuecomment-6628735595

   @nielsbasjes Your code does check each repository's own ID before that same 
repository's mirrors. The distinction is **all repositories' own IDs first**, 
before checking **any** mirror aliases.
   
   For example, suppose the effective list is ordered like this and 
`referenceRepo` is `central`:
   
   1. `mirror-central`, with `central` in its `getMirroredRepositories()`
   2. A repository whose own ID is `central`
   
   Your current loop returns entry 1 through its mirror alias before it reaches 
entry 2. With two passes, the first pass finds entry 2 by its own ID; the 
mirror fallback is used only if no effective repository has that ID:
   
   ```java
   for (RemoteRepository repo : repositories) {
       if (referenceRepo.equals(repo.getId())) {
           return repo;
       }
   }
   for (RemoteRepository repo : repositories) {
       for (RemoteRepository mirrored : repo.getMirroredRepositories()) {
           if (referenceRepo.equals(mirrored.getId())) {
               return repo;
           }
       }
   }
   ```
   
   Here `repositories` is just a placeholder for the existing repository list. 
The two-pass version preserves the old exact-ID lookup precedence while adding 
the mirror fallback. For the usual case where only `mirror-central` is present, 
both approaches return the same repository and fix #281.
   
   As noted above, the two-entry list is a constructed unit-test case; I 
haven't established that Resolver produces it in a real configuration. This 
explains the optional precedence suggestion, rather than demonstrating another 
production bug. Sorry my earlier explanation wasn't clearer.
   
   AI assistance: Codex helped verify the current diff and draft this 
explanation.
   


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