[
https://issues.apache.org/jira/browse/MRESOLVER-376?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17738943#comment-17738943
]
ASF GitHub Bot commented on MRESOLVER-376:
------------------------------------------
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.
> StackOverflowError at BfDependencyCollector.processDependency
> -------------------------------------------------------------
>
> Key: MRESOLVER-376
> URL: https://issues.apache.org/jira/browse/MRESOLVER-376
> Project: Maven Resolver
> Issue Type: Bug
> Components: Resolver
> Affects Versions: 1.9.13
> Reporter: Snjezana Peco
> Priority: Major
> Fix For: 1.9.14
>
>
> Steps to reproduce:
> {code:java}
> $ mvn -v
> Apache Maven 3.9.3 (21122926829f1ead511c958d89bd2f672198ae9f))
> $ git clone [email protected]:snowflakedb/snowflake-kafka-connector.git
> $ cd snowflake-kafka-connector
> $ mvn clean verify -Daether.dependencyCollector.impl=bf {code}
>
> A related issue -
> [https://github.com/redhat-developer/vscode-java/issues/3085]
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)