maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hervé Boutemy (JIRA) <j...@apache.org>
Subject [jira] [Updated] (MNG-6737) StackOverflowError when version ranges are unsolvable and graph contains a cycle
Date Fri, 16 Aug 2019 18:36:00 GMT

     [ https://issues.apache.org/jira/browse/MNG-6737?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Hervé Boutemy updated MNG-6737:
-------------------------------
    Issue Type: Bug  (was: Improvement)

> StackOverflowError when version ranges are unsolvable and graph contains a cycle
> --------------------------------------------------------------------------------
>
>                 Key: MNG-6737
>                 URL: https://issues.apache.org/jira/browse/MNG-6737
>             Project: Maven
>          Issue Type: Bug
>    Affects Versions: 3.6.1
>            Reporter: Tomo Suzuki
>            Priority: Major
>
> Maven throws StackOverflowError when version ranges are unsolvable and the dependency
graph contains a cycle.
> {code:java}
> $ mvn install
> ...
> [INFO] --------------------------< suztomo:module-c >--------------------------
> [INFO] Building module-c 1.0
> [INFO] --------------------------------[ jar ]---------------------------------
> [INFO] ------------------------------------------------------------------------
> [INFO] BUILD FAILURE
> [INFO] ------------------------------------------------------------------------
> [INFO] Total time:  0.406 s
> [INFO] Finished at: 2019-08-16T12:10:30-04:00
> [INFO] ------------------------------------------------------------------------
> ...
> Exception in thread "main" java.lang.StackOverflowError
> 	at org.eclipse.aether.graph.DefaultDependencyNode.accept(DefaultDependencyNode.java:341)
> 	at org.eclipse.aether.graph.DefaultDependencyNode.accept(DefaultDependencyNode.java:345)
> 	at org.eclipse.aether.graph.DefaultDependencyNode.accept(DefaultDependencyNode.java:345)
> 	at org.eclipse.aether.graph.DefaultDependencyNode.accept(DefaultDependencyNode.java:345)
> 	at org.eclipse.aether.graph.DefaultDependencyNode.accept(DefaultDependencyNode.java:345)
> 	at org.eclipse.aether.graph.DefaultDependencyNode.accept(DefaultDependencyNode.java:345)
> ...(omitting many lines)...
>  {code}
> h1. Example 
> Example project to reproduce the issue:  [https://github.com/suztomo/maven-cyclic-dependency-with-range] 
> h1. Diagnosis
> In the example above, because of a version conflict on grpc-core (1.21.0 v.s. 1.16.1), [org.eclipse.aether.util.graph.transformer.NearestVersionSelector.newFailure|https://github.com/apache/maven-resolver/blob/maven-resolver-1.4.0/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/transformer/NearestVersionSelector.java#L158] tries
to throw UnsolvableVersionConflictExceptoin. However, before throwing the exception PathRecordingDependencyVisitor
visits nodes in the dependency graph and the graph contains a cycle. The visitor goes to infinite
recursion in visiting the cyclic path, resulting in StackOverflowError.
>  
> {code:java}
> private UnsolvableVersionConflictException newFailure( final ConflictContext context
)
> {
>  ...
>  PathRecordingDependencyVisitor visitor = new PathRecordingDependencyVisitor( filter
);
>  context.getRoot().accept( visitor );
>  return new UnsolvableVersionConflictException( visitor.getPaths() );
> }{code}
>  
> The cycle in the graph consists of module-a and module-b as illustrated below:
> {code:java}
> module-c:1.0.0
> +- module-b:2.0.0
>  +- module-a:1.0.0
>  +- module-b:0.0.1
>  +- module-b:1.0.0
>  | +- module-a:1.0.0
>  | +- module-b:0.0.1
>  | +- module-b:1.0.0
>    ...{code}
>  



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

Mime
View raw message