cstamas commented on PR #309: URL: https://github.com/apache/maven-resolver/pull/309#issuecomment-1614300205
Things to be aware: * RelocatedArtifact (implemented in Maven) https://github.com/apache/maven/blob/maven-3.9.x/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RelocatedArtifact.java * ArtifactDescriptorReader (also implemented in Maven): https://github.com/apache/maven/blob/maven-3.9.x/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java#L299-L308 * async resolver has a Map<Artifact, ArtifactDescriptor> that uses computeIfAbsent, hence if key once added, will not be re-added during resolution Steps happening: * BF asks for `junit:junit-dep:4.11` descriptor async resolution * descriptor reader returns `ArtifactDescriptorResult` that carries `RelocatedArtifact` as d.artifact (that contains GAVs for relocation target `junit:junit:4.11`) while descriptor contains `junit:junit-dep:4.11` data, so even redirects are there * this descriptor is being put into map (computeIfAbsent) as `junit:junit:4.11` -> `ArtifactDescriptorResult` (that of `junit:junit-dep:4.11` * next, relocation target `junit:junit:4.11` descriptor is asked, but the entry above is returned (that is actually descriptor of `junit;junit-dep:4.11` that AGAIN contains relocation * and so on, relocation target is being asked for over and over again, but the resolver map returns relocated artifact descriptor over and over again, so "constant relocation loop happens". @caiwei-ebay2 yes, very simple to reproduce, and this above is what I saw during debug (and locally added some logging). Problem is that `RelocatedArtifact` is completely opaque in resolver (as it is implemented in maven-resolver-provider), as IMHO simplest would be something like this (but there is no such method either): ``` Artifact key = artifactDescriptor.artifact if (key instance of RelocatedArtifact) { key = ((RelocatedArtifact) key).getOriginalArtifact(); } ``` Ultimately, problem is this "mixup" that in the map, the relocated artifact descriptor is stored under relocation target key, and here a loop starts, as relocation target mapping will again return relocated artifact descriptor. -- 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]
