ferstl / depgraph-maven-plugin

A Maven plugin that generates dependency graphs in various formats (DOT, GML, PlantUML, JSON and Text)
Apache License 2.0
561 stars 85 forks source link

Execution default-cli of goal com.github.ferstl:depgraph-maven-plugin:3.3.1:graph failed.: ConcurrentModificationException #159

Closed tonjohn closed 2 years ago

tonjohn commented 2 years ago

[ERROR] Failed to execute goal com.github.ferstl:depgraph-maven-plugin:3.3.1:graph (default-cli) on project my-project-server: Execution default-cli of goal com.github.ferstl:depgraph-maven-plugin:3.3.1:gr aph failed.: ConcurrentModificationException -> [Help 1]

In debugging why the VSCode extension Maven for Java failed to load dependencies for one of the modules, I see that com.github.ferstl:depgraph-maven-plugin:3.3.1:graph is failing due to a ConcurrentModificationException being thrown at com.github.ferstl.depgraph.graph.text.TextGraphFormatter$TextGraphWriter.writeChildren (TextGraphFormatter.java:107). None of the other modules in my project hit this error - they all work.

Here (mavenUtils.ts:47) is the command that the Maven for Java extension runs when I click to expand the Dependencies list:

mvn com.github.ferstl:depgraph-maven-plugin:3.3.1:graph -DgraphFormat=text -DshowDuplicates -DshowConflicts -DshowVersions -DshowGroupIds -DoutputDirectory="c:\Users\jdoe\AppData\Roaming\Code\User\workspaceStorage\4e542b539f681445e91db13053cfaa49\vscjava.vscode-maven" -DoutputFileName="245be55e97920914a630bdba648cd222.deps.txt" -f "c:\src\my-project\server\pom.xml" -X

Detailed Error Logs

[ERROR] Failed to execute goal com.github.ferstl:depgraph-maven-plugin:3.3.1:graph (default-cli) on project my-project-server: Execution default-cli of goal com.github.ferstl:depgraph-maven-plugin:3.3.1:gr
aph failed.: ConcurrentModificationException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.ferstl:depgraph-maven-plugin:3.3.1:graph (default-cli) on project my-project-server: Execution default-cli of goal
com.github.ferstl:depgraph-maven-plugin:3.3.1:graph failed.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:954)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal com.github.ferstl:depgraph-maven-plugin:3.3.1:graph failed.
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:954)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: java.util.ConcurrentModificationException
    at java.util.ArrayList$Itr.checkForComodification (ArrayList.java:909)
    at java.util.ArrayList$Itr.next (ArrayList.java:859)
    at com.github.ferstl.depgraph.graph.text.TextGraphFormatter$TextGraphWriter.writeChildren (TextGraphFormatter.java:107)
    at com.github.ferstl.depgraph.graph.text.TextGraphFormatter$TextGraphWriter.writeChildren (TextGraphFormatter.java:119)
    at com.github.ferstl.depgraph.graph.text.TextGraphFormatter$TextGraphWriter.writeChildren (TextGraphFormatter.java:119)
    at com.github.ferstl.depgraph.graph.text.TextGraphFormatter$TextGraphWriter.writeChildren (TextGraphFormatter.java:119)
    at com.github.ferstl.depgraph.graph.text.TextGraphFormatter$TextGraphWriter.writeChildren (TextGraphFormatter.java:119)
    at com.github.ferstl.depgraph.graph.text.TextGraphFormatter$TextGraphWriter.write (TextGraphFormatter.java:79)
    at com.github.ferstl.depgraph.graph.text.TextGraphFormatter.format (TextGraphFormatter.java:41)
    at com.github.ferstl.depgraph.graph.GraphBuilder.toString (GraphBuilder.java:155)
    at com.github.ferstl.depgraph.dependency.SimpleGraphFactory.createGraph (SimpleGraphFactory.java:49)
    at com.github.ferstl.depgraph.AbstractGraphMojo.execute (AbstractGraphMojo.java:277)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:954)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
tonjohn commented 2 years ago

After I did the following, I got it to work:

Sorry for the false alarm!

Edit: I'm a liar! Still having the issue. Not sure how I got it to work the one time...

ngrigoriev commented 2 years ago

Actually, still happening for me even after clean install. Interestingly enough, exactly the same command runs fine in my terminal, which means there is something special in how VS Code extension runs it.

/opt/java/apache-maven-3.6.1/bin/mvn -N com.github.ferstl:depgraph-maven-plugin:3.3.1:graph -DgraphFormat=text -DshowConflicts -DshowVersions -DshowGroupIds -DoutputDirectory="/Users/myuser/Library/Application Support/Code/User/workspaceStorage/fd0c3c196085f9c39b952636280de529/vscjava.vscode-maven" -DoutputFileName="f1b445acc55d9961eb54baded6d11987.deps.txt" -f /Users/myuser/git/gk2/media-handler/pom.xml

I cannnot reproduce this issue at least by replicating the exact shell environment. But I can indirectly confirm that the bug does exist. The following modification does not fail any unit tests and allows this plug-in to run successfully via this extension:

diff --git a/src/main/java/com/github/ferstl/depgraph/graph/text/TextGraphFormatter.java b/src/main/java/com/github/ferstl/depgraph/graph/text/TextGraphFormatter.java
index e568d5f..21103fa 100644
--- a/src/main/java/com/github/ferstl/depgraph/graph/text/TextGraphFormatter.java
+++ b/src/main/java/com/github/ferstl/depgraph/graph/text/TextGraphFormatter.java
@@ -101,7 +101,8 @@ public class TextGraphFormatter implements com.github.ferstl.depgraph.graph.Grap

     private void writeChildren(StringBuilder stringBuilder, String parent, Set<String> currentPath, List<Boolean> lastParents) {
       Collection<Edge> edges = this.relations.get(parent);
-      Iterator<Edge> edgeIterator = edges.iterator();
+      Collection<Edge> edgesCopy = new ArrayList<>(edges);
+      Iterator<Edge> edgeIterator = edgesCopy.iterator();

       while (edgeIterator.hasNext()) {
         Edge edge = edgeIterator.next();
ferstl commented 2 years ago

Hi @ngrigoriev Thank you for the analysis. This is really strange. First, because the issue is not reproducible when executed on the command line. Second, running clean install beforehand (as described by @tonjohn) should not change the behaviour.

My only explanation for the exception is:

The reason why this exception is not reproducible could be a different dependency order which is somehow triggered by VS code or by running clean install first. Your suggested fix seems reasonable. I'll add it to the plugin.

Cheers, Stefan

ferstl commented 2 years ago

@tonjohn @ngrigoriev Are your projects where this problems occurred publicly available. I am still interested in finding a way of reproducing the problem.

ferstl commented 2 years ago

I released version 3.3.2 with your suggested fix and informed the vscode-maven project.

ngrigoriev commented 2 years ago

@tonjohn @ngrigoriev Are your projects where this problems occurred publicly available. I am still interested in finding a way of reproducing the problem.

No, my project is private but I feel obliged to contribute as much as I can :)

I tested first a couple of random spring boot demo projects from GitHub and could not get the issue reproducible (after reverting to the original 3.3.1 without the hack). So I took my original project, ran it through help:effective-pom. Then removes all code, removed all private references, randomized some values etc, so it is clean. I have removed all internal dependencies. The problem was still reproducible in VS Code. hello-world.zip

This build works fine if I run it manually (tried several different Maven versions):

[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for mygroup:hello-world:jar:1.5.13-SNAPSHOT
[WARNING] Reporting configuration should be done in <reporting> section, not in maven-site-plugin <configuration> as reportPlugins parameter. @ line 6681, column 24
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO] ------------------------------------------------------------------------
[INFO] Detecting the operating system and CPU architecture
[INFO] ------------------------------------------------------------------------
[INFO] os.detected.name: osx
[INFO] os.detected.arch: x86_64
[INFO] os.detected.version: 12.4
[INFO] os.detected.version.major: 12
[INFO] os.detected.version.minor: 4
[INFO] os.detected.classifier: osx-x86_64
[INFO] 
[INFO] ------------------------< mygroup:hello-world >-------------------------
[INFO] Building hello-world 1.5.13-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for org.perfkit.sjk.parsers:sjk-jfr5:jar:0.5 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.perfkit.sjk.parsers:sjk-jfr6:jar:0.7 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.perfkit.sjk.parsers:sjk-nps:jar:0.5 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] 
[INFO] --- depgraph-maven-plugin:3.3.1:graph (default-cli) @ hello-world ---
[INFO] Dependency graph:
mygroup:hello-world:1.5.13-SNAPSHOT:compile
+- org.cassandraunit:cassandra-unit-spring:4.3.1.0:test
|  +- org.cassandraunit:cassandra-unit:4.3.1.0:test
|  |  +- junit:junit:4.13.2:test
|  |  +- org.apache.cassandra:cassandra-all:4.0.4:test (omitted for conflict: 3.11.5)
|  |  |  +- org.xerial.snappy:snappy-java:1.1.2.6:test
|  |  |  +- org.lz4:lz4-java:1.8.0:test
|  |  |  +- com.google.guava:guava:27.0-jre:test
|  |  |  |  \- com.google.j2objc:j2objc-annotations:1.3:test (omitted for conflict: 1.1)
|  |  |  +- commons-cli:commons-cli:1.1:test
|  |  |  +- commons-codec:commons-codec:1.15:test
|  |  |  +- org.apache.commons:commons-lang3:3.12.0:test
|  |  |  +- org.apache.commons:commons-math3:3.2:test
|  |  |  +- org.antlr:ST4:4.0.8:test
|  |  |  +- org.antlr:antlr-runtime:3.5.2:test
|  |  |  +- org.slf4j:slf4j-api:1.7.36:compile
|  |  |  +- org.slf4j:log4j-over-slf4j:1.7.36:test
|  |  |  +- org.slf4j:jcl-over-slf4j:1.7.36:test
|  |  |  +- com.fasterxml.jackson.core:jackson-core:2.13.3:compile
|  |  |  +- com.fasterxml.jackson.core:jackson-databind:2.13.3:compile
|  |  |  +- com.fasterxml.jackson.core:jackson-annotations:2.13.3:compile
|  |  |  +- com.googlecode.json-simple:json-simple:1.1:test
|  |  |  +- com.boundary:high-scale-lib:1.0.6:test
|  |  |  +- org.yaml:snakeyaml:1.30:compile
|  |  |  +- org.mindrot:jbcrypt:0.4:test
|  |  |  +- io.airlift:airline:0.8:test
|  |  |  |  \- com.google.guava:guava:27.0-jre:test (omitted for conflict: 21.0)
|  |  |  +- io.dropwizard.metrics:metrics-core:4.2.10:compile
|  |  |  +- io.dropwizard.metrics:metrics-jvm:4.2.10:test
|  |  |  +- io.dropwizard.metrics:metrics-logback:4.2.10:test
|  |  |  |  +- ch.qos.logback:logback-core:1.2.9:compile/test (omitted for conflict: 1.2.11)
|  |  |  |  \- ch.qos.logback:logback-classic:1.2.9:compile (omitted for conflict: 1.2.11)
|  |  |  |     \- ch.qos.logback:logback-core:1.2.9:compile/test (omitted for conflict: 1.2.11)
|  |  |  +- com.addthis.metrics:reporter-config3:3.0.3:test
|  |  |  |  \- com.addthis.metrics:reporter-config-base:3.0.3:test
|  |  |  +- com.clearspring.analytics:stream:2.5.2:test
|  |  |  +- ch.qos.logback:logback-core:1.2.9:compile/test (omitted for conflict: 1.2.11)
|  |  |  +- ch.qos.logback:logback-classic:1.2.9:compile (omitted for conflict: 1.2.11)
|  |  |  +- net.java.dev.jna:jna:5.6.0:compile/test
|  |  |  +- com.github.jbellis:jamm:0.3.2:test
|  |  |  +- io.netty:netty-all:4.1.78.Final:test
|  |  |  |  +- io.netty:netty-codec-dns:4.1.78.Final:test
|  |  |  |  +- io.netty:netty-codec-haproxy:4.1.78.Final:test
|  |  |  |  +- io.netty:netty-codec-http:4.1.78.Final:test
|  |  |  |  +- io.netty:netty-codec-http2:4.1.78.Final:test
|  |  |  |  +- io.netty:netty-codec-memcache:4.1.78.Final:test
|  |  |  |  +- io.netty:netty-codec-mqtt:4.1.78.Final:test
|  |  |  |  +- io.netty:netty-codec-redis:4.1.78.Final:test
|  |  |  |  +- io.netty:netty-codec-smtp:4.1.78.Final:test
|  |  |  |  +- io.netty:netty-codec-socks:4.1.78.Final:test
|  |  |  |  +- io.netty:netty-codec-stomp:4.1.78.Final:test
|  |  |  |  +- io.netty:netty-codec-xml:4.1.78.Final:test
|  |  |  |  +- io.netty:netty-handler-proxy:4.1.78.Final:test
|  |  |  |  +- io.netty:netty-resolver-dns:4.1.78.Final:test
|  |  |  |  +- io.netty:netty-transport-rxtx:4.1.78.Final:test
|  |  |  |  +- io.netty:netty-transport-sctp:4.1.78.Final:test
|  |  |  |  +- io.netty:netty-transport-udt:4.1.78.Final:test
|  |  |  |  +- io.netty:netty-transport-classes-epoll:4.1.78.Final:test
|  |  |  |  +- io.netty:netty-transport-classes-kqueue:4.1.78.Final:test
|  |  |  |  +- io.netty:netty-resolver-dns-classes-macos:4.1.78.Final:test
|  |  |  |  +- io.netty:netty-transport-native-epoll:4.1.78.Final:test
|  |  |  |  +- io.netty:netty-transport-native-epoll:4.1.78.Final:test
|  |  |  |  +- io.netty:netty-transport-native-kqueue:4.1.78.Final:test
|  |  |  |  +- io.netty:netty-transport-native-kqueue:4.1.78.Final:test
|  |  |  |  +- io.netty:netty-resolver-dns-native-macos:4.1.78.Final:test
|  |  |  |  \- io.netty:netty-resolver-dns-native-macos:4.1.78.Final:test
|  |  |  +- net.openhft:chronicle-queue:5.20.123:test
|  |  |  |  \- commons-cli:commons-cli:1.1:test (omitted for conflict: 1.4)
|  |  |  +- net.openhft:chronicle-core:2.20.126:test
|  |  |  +- net.openhft:chronicle-bytes:2.20.111:test
|  |  |  |  \- net.openhft:chronicle-core:2.20.126:test (omitted for conflict: 2.20.125)
|  |  |  +- net.openhft:chronicle-wire:2.20.117:test
|  |  |  |  +- net.openhft:chronicle-core:2.20.126:test (omitted for conflict: 2.20.125)
|  |  |  |  +- net.openhft:chronicle-bytes:2.20.111:test (omitted for conflict: 2.20.110)
|  |  |  |  \- net.openhft:chronicle-threads:2.20.111:test (omitted for conflict: 2.20.110)
|  |  |  |     \- net.openhft:chronicle-core:2.20.126:test (omitted for conflict: 2.20.125)
|  |  |  +- net.openhft:chronicle-threads:2.20.111:test
|  |  |  +- org.fusesource:sigar:1.6.4:test
|  |  |  +- org.eclipse.jdt.core.compiler:ecj:4.6.1:test
|  |  |  +- org.caffinitas.ohc:ohc-core:0.5.1:test
|  |  |  |  +- com.google.guava:guava:27.0-jre:test (omitted for conflict: 16.0)
|  |  |  |  \- net.java.dev.jna:jna:5.6.0:compile/test (omitted for conflict: 4.1.0)
|  |  |  +- org.caffinitas.ohc:ohc-core-j8:0.5.1:test
|  |  |  +- com.github.ben-manes.caffeine:caffeine:2.8.6:compile (omitted for conflict: 2.9.3)
|  |  |  |  +- org.checkerframework:checker-qual:3.7.0:compile
|  |  |  |  \- com.google.errorprone:error_prone_annotations:2.4.0:compile
|  |  |  +- org.jctools:jctools-core:3.1.0:test
|  |  |  +- org.ow2.asm:asm:7.1:compile
|  |  |  +- com.carrotsearch:hppc:0.8.1:test
|  |  |  +- org.gridkit.jvmtool:sjk-cli:0.14:test
|  |  |  +- org.gridkit.jvmtool:sjk-core:0.14:test
|  |  |  +- org.gridkit.jvmtool:sjk-stacktrace:0.14:test
|  |  |  +- org.gridkit.jvmtool:mxdump:0.14:test
|  |  |  +- org.gridkit.lab:jvm-attach-api:1.5:test
|  |  |  +- com.beust:jcommander:1.30:test
|  |  |  +- org.gridkit.jvmtool:sjk-json:0.14:test
|  |  |  +- com.github.luben:zstd-jni:1.5.0-4:test
|  |  |  +- org.psjava:psjava:0.1.19:test
|  |  |  +- io.netty:netty-tcnative-boringssl-static:2.0.53.Final:test
|  |  |  |  +- io.netty:netty-tcnative-classes:2.0.53.Final:test
|  |  |  |  +- io.netty:netty-tcnative-boringssl-static:2.0.53.Final:test
|  |  |  |  +- io.netty:netty-tcnative-boringssl-static:2.0.53.Final:test
|  |  |  |  +- io.netty:netty-tcnative-boringssl-static:2.0.53.Final:test
|  |  |  |  +- io.netty:netty-tcnative-boringssl-static:2.0.53.Final:test
|  |  |  |  \- io.netty:netty-tcnative-boringssl-static:2.0.53.Final:test
|  |  |  +- javax.inject:javax.inject:1:test
|  |  |  +- com.google.j2objc:j2objc-annotations:1.3:test
|  |  |  +- org.hdrhistogram:HdrHistogram:2.1.9:compile
|  |  |  +- de.jflex:jflex:1.8.2:test
|  |  |  |  \- com.github.vbmacher:java-cup-runtime:11b-20160615:test
|  |  |  +- com.github.rholder:snowball-stemmer:1.3.0.581.1:test
|  |  |  \- com.googlecode.concurrent-trees:concurrent-trees:2.4.0:test
|  |  \- net.java.dev.jna:jna:5.6.0:compile/test (omitted for conflict: 4.1.0)
|  +- org.springframework:spring-context:5.3.21:compile
|  |  +- org.springframework:spring-aop:5.3.21:compile
|  |  +- org.springframework:spring-beans:5.3.21:compile
|  |  \- org.springframework:spring-expression:5.3.21:compile
|  +- org.springframework:spring-test:5.3.21:test
|  +- org.hamcrest:hamcrest-core:2.2:test
|  \- org.hamcrest:hamcrest-library:2.2:test
+- org.apache.cassandra:cassandra-all:4.0.4:test
+- org.testcontainers:cassandra:1.17.3:test
|  +- org.testcontainers:database-commons:1.17.3:test
|  |  \- org.testcontainers:testcontainers:1.17.3:test
|  |     +- org.apache.commons:commons-compress:1.21:test
|  |     +- org.rnorth.duct-tape:duct-tape:1.0.8:test
|  |     |  \- org.jetbrains:annotations:17.0.0:test
|  |     +- com.github.docker-java:docker-java-api:3.2.13:test
|  |     \- com.github.docker-java:docker-java-transport-zerodep:3.2.13:test
|  |        +- com.github.docker-java:docker-java-transport:3.2.13:test
|  |        \- net.java.dev.jna:jna:5.6.0:compile/test (omitted for conflict: 5.8.0)
|  \- com.datastax.cassandra:cassandra-driver-core:3.7.1:test
|     +- com.google.guava:guava:27.0-jre:test (omitted for conflict: 19.0)
|     +- com.github.jnr:jnr-ffi:2.1.7:compile
|     |  +- com.github.jnr:jffi:1.2.16:compile
|     |  +- com.github.jnr:jffi:1.2.16:runtime
|     |  +- org.ow2.asm:asm:7.1:compile (omitted for conflict: 5.0.3)
|     |  +- org.ow2.asm:asm-commons:5.0.3:compile
|     |  +- org.ow2.asm:asm-analysis:5.0.3:compile
|     |  +- org.ow2.asm:asm-tree:5.0.3:compile
|     |  |  \- org.ow2.asm:asm:7.1:compile (omitted for conflict: 5.0.3)
|     |  +- org.ow2.asm:asm-util:5.0.3:compile
|     |  \- com.github.jnr:jnr-x86asm:1.0.2:compile
|     \- com.github.jnr:jnr-posix:3.1.15:compile (omitted for conflict: 3.0.44)
|        +- com.github.jnr:jnr-ffi:2.1.7:compile (omitted for conflict: 2.2.11)
|        \- com.github.jnr:jnr-constants:0.10.3:compile
+- org.freedesktop.gstreamer:gst1-java-core:1.4.0:compile
|  \- net.java.dev.jna:jna:5.6.0:compile/test (omitted for conflict: 5.2.0)
+- io.lettuce:lettuce-core:6.1.8.RELEASE:compile
|  +- io.netty:netty-common:4.1.78.Final:compile
|  +- io.netty:netty-transport:4.1.78.Final:compile
|  \- io.projectreactor:reactor-core:3.4.19:compile
+- org.springframework.boot:spring-boot-starter-cache:2.7.1:compile
|  +- org.springframework.boot:spring-boot-starter:2.7.1:compile
|  |  +- org.springframework.boot:spring-boot:2.7.1:compile
|  |  +- org.springframework.boot:spring-boot-autoconfigure:2.7.1:compile
|  |  +- org.springframework.boot:spring-boot-starter-logging:2.7.1:compile
|  |  |  +- ch.qos.logback:logback-classic:1.2.9:compile (omitted for conflict: 1.2.11)
|  |  |  +- org.apache.logging.log4j:log4j-to-slf4j:2.17.2:compile
|  |  |  |  \- org.apache.logging.log4j:log4j-api:2.17.2:compile
|  |  |  \- org.slf4j:jul-to-slf4j:1.7.36:compile
|  |  \- jakarta.annotation:jakarta.annotation-api:1.3.5:compile
|  \- org.springframework:spring-context-support:5.3.21:compile
+- com.github.ben-manes.caffeine:caffeine:2.8.6:compile
+- com.datastax.oss:java-driver-core:4.14.1:compile
|  +- com.datastax.oss:native-protocol:1.5.1:compile
|  +- com.datastax.oss:java-driver-shaded-guava:25.1-jre-graal-sub-1:compile
|  +- com.typesafe:config:1.4.1:compile
|  +- com.github.jnr:jnr-posix:3.1.15:compile
|  +- org.hdrhistogram:HdrHistogram:2.1.9:compile (omitted for conflict: 2.1.12)
|  +- org.reactivestreams:reactive-streams:1.0.4:compile
|  +- com.github.stephenc.jcip:jcip-annotations:1.0-1:compile
|  \- com.github.spotbugs:spotbugs-annotations:3.1.12:compile
|     \- com.google.code.findbugs:jsr305:3.0.2:compile
+- com.google.code.gson:gson:2.8.9:compile
+- io.opentracing:opentracing-mock:0.33.0:test
|  +- io.opentracing:opentracing-api:0.33.0:test
|  +- io.opentracing:opentracing-noop:0.33.0:test
|  \- io.opentracing:opentracing-util:0.33.0:test
+- javax.validation:validation-api:2.0.1.Final:compile
+- net.minidev:accessors-smart:2.4.7:compile
|  \- org.ow2.asm:asm:7.1:compile (omitted for conflict: 9.1)
+- net.minidev:json-smart:2.4.7:compile
+- org.apache.tomcat.embed:tomcat-embed-core:9.0.64:compile
+- org.apache.tomcat.embed:tomcat-embed-websocket:9.0.64:compile
+- org.apache.tomcat:tomcat-annotations-api:9.0.64:compile
+- org.assertj:assertj-core:3.22.0:test
+- org.junit.jupiter:junit-jupiter:5.7.0:test
|  +- org.junit.jupiter:junit-jupiter-api:5.7.0:test
|  |  +- org.apiguardian:apiguardian-api:1.1.0:test
|  |  +- org.opentest4j:opentest4j:1.2.0:test
|  |  \- org.junit.platform:junit-platform-commons:1.7.0:test
|  +- org.junit.jupiter:junit-jupiter-params:5.7.0:test
|  \- org.junit.jupiter:junit-jupiter-engine:5.7.0:test
|     \- org.junit.platform:junit-platform-engine:1.7.0:test
+- org.mockito:mockito-junit-jupiter:3.6.28:test
|  \- org.mockito:mockito-core:4.5.1:test
|     +- net.bytebuddy:byte-buddy:1.12.11:test
|     +- net.bytebuddy:byte-buddy-agent:1.12.11:test
|     \- org.objenesis:objenesis:3.2:test
+- org.owasp.encoder:encoder:1.2.2:compile
+- org.springframework.boot:spring-boot-starter-web:2.7.1:compile
|  +- org.springframework.boot:spring-boot-starter-json:2.7.1:compile
|  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.13.3:compile
|  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.3:compile
|  |  \- com.fasterxml.jackson.module:jackson-module-parameter-names:2.13.3:compile
|  +- org.springframework.boot:spring-boot-starter-tomcat:2.7.1:compile
|  |  \- org.apache.tomcat.embed:tomcat-embed-el:9.0.64:compile
|  +- org.springframework:spring-web:5.3.21:compile
|  \- org.springframework:spring-webmvc:5.3.21:compile
+- org.springframework.boot:spring-boot-starter-test:2.7.1:test
|  +- org.springframework.boot:spring-boot-test:2.7.1:test
|  +- org.springframework.boot:spring-boot-test-autoconfigure:2.7.1:test
|  +- com.jayway.jsonpath:json-path:2.7.0:test
|  +- jakarta.xml.bind:jakarta.xml.bind-api:2.3.3:test
|  |  \- jakarta.activation:jakarta.activation-api:1.2.2:test
|  +- org.hamcrest:hamcrest:2.2:test
|  +- org.skyscreamer:jsonassert:1.5.0:test
|  |  \- com.vaadin.external.google:android-json:0.0.20131108.vaadin1:test
|  +- org.springframework:spring-core:5.3.21:compile
|  |  \- org.springframework:spring-jcl:5.3.21:compile
|  \- org.xmlunit:xmlunit-core:2.9.0:test
+- org.powermock:powermock-api-easymock:2.0.7:test
|  +- org.powermock:powermock-api-support:2.0.7:test
|  |  +- org.powermock:powermock-reflect:2.0.7:test
|  |  |  \- org.objenesis:objenesis:3.2:test (omitted for conflict: 3.0.1)
|  |  \- org.powermock:powermock-core:2.0.7:test
|  |     \- org.javassist:javassist:3.27.0-GA:test
|  +- cglib:cglib-nodep:3.2.9:test
|  \- org.easymock:easymock:4.0.1:test
|     \- org.objenesis:objenesis:3.2:test (omitted for conflict: 3.0.1)
+- org.springframework.boot:spring-boot-starter-actuator:2.7.1:compile
|  +- org.springframework.boot:spring-boot-actuator-autoconfigure:2.7.1:compile
|  |  \- org.springframework.boot:spring-boot-actuator:2.7.1:compile
|  \- io.micrometer:micrometer-core:1.9.1:compile
|     +- org.hdrhistogram:HdrHistogram:2.1.9:compile (omitted for conflict: 2.1.12)
|     \- org.latencyutils:LatencyUtils:2.0.3:runtime
+- org.springframework.boot:spring-boot-configuration-processor:2.7.1:compile (optional)
+- io.netty:netty-codec:4.1.78.Final:compile
|  \- io.netty:netty-buffer:4.1.78.Final:compile
+- io.netty:netty-handler:4.1.78.Final:compile
|  +- io.netty:netty-resolver:4.1.78.Final:compile
|  \- io.netty:netty-transport-native-unix-common:4.1.78.Final:compile
+- ch.qos.logback:logback-core:1.2.9:compile/test
\- ch.qos.logback:logback-classic:1.2.9:compile

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.988 s
[INFO] Finished at: 2022-07-27T20:21:36-04:00
[INFO] ------------------------------------------------------------------------

It fails perfectly in VS Code as follows:

vs-code-mvn-log.txt

VS Code info:

Version: 1.69.2 Commit: 3b889b090b5ad5793f524b5d1d39fda662b96a2a Date: 2022-07-18T16:12:57.074Z (1 wk ago) Electron: 18.3.5 Chromium: 100.0.4896.160 Node.js: 16.13.2 V8: 10.0.139.17-electron.0 OS: Darwin x64 21.5.0

Installed VS Code extensions:

ban.spellright-3.0.72 bazelbuild.vscode-bazel-0.5.0 davidanson.vscode-markdownlint-0.47.0 dcortes92.freemarker-0.0.9 dotjoshjohnson.xml-2.5.1 formulahendry.auto-close-tag-0.5.14 formulahendry.auto-rename-tag-0.1.10 gabrielbb.vscode-lombok-1.0.1 golang.go-0.35.1 ipedrazas.kubernetes-snippets-0.1.9 lextudio.restructuredtext-189.1.0 ms-azuretools.vscode-docker-1.22.1 ms-dotnettools.csharp-1.25.0-darwin-x64 ms-kubernetes-tools.vscode-kubernetes-tools-1.3.10 ms-python.anaconda-extension-pack-1.0.1 ms-python.python-2022.10.1 ms-python.vscode-pylance-2022.7.40 ms-toolsai.jupyter-2022.6.1201981810 ms-toolsai.jupyter-keymap-1.0.0 ms-toolsai.jupyter-renderers-1.0.9 ms-vscode-remote.remote-containers-0.241.3 ms-vscode.powershell-2022.6.3 naco-siren.gradle-language-0.2.3 owenfarrell.vscode-microtask-1.0.3 peterj.proto-0.0.2 pivotal.vscode-boot-dev-pack-0.1.0 pivotal.vscode-manifest-yaml-1.36.0 redhat.java-1.9.0-darwin-x64 redhat.vscode-yaml-1.9.1 vincaslt.highlight-matching-tag-0.10.1 visualstudioexptteam.vscodeintellicode-1.2.22 vscjava.vscode-java-debug-0.42.0 vscjava.vscode-java-debug-0.43.0 vscjava.vscode-java-dependency-0.20.0 vscjava.vscode-java-dependency-0.21.0 vscjava.vscode-java-pack-0.25.0 vscjava.vscode-java-test-0.36.0 vscjava.vscode-maven-0.36.0 vscjava.vscode-maven-0.37.0 vscodevim.vim-1.23.1 zxh404.vscode-proto3-0.5.5

Let me know if I can provide more information.

ngrigoriev commented 2 years ago

@tonjohn I had a silly thought this morning and I was able to reproduce the issue without VS Code. I really wanted to understand what was going on since there are not too many things the parent process can do to the child to change its behavior - environment (no, verified that), stdin/stdout and that's all. So I decided to capture the exact thing. Turned out, VS Code runs the build like this:

/usr/bin/java -classpath /opt/java/apache-maven-3.6.1/boot/plexus-classworlds-2.6.0.jar -Dclassworlds.conf=/opt/java/apache-maven-3.6.1/bin/m2.conf -Dmaven.home=/opt/java/apache-maven-3.6.1 -Dlibrary.jansi.path=/opt/java/apache-maven-3.6.1/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/Users/myuser/git/tmp/hello-world org.codehaus.plexus.classworlds.launcher.Launcher -N com.github.ferstl:depgraph-maven-plugin:3.3.1:graph -DgraphFormat=text -DshowDuplicates -DshowConflicts -DshowVersions -DshowGroupIds -DoutputDirectory=/Users/myuser/Library/Application\ Support/Code/User/workspaceStorage/cb61b259338e1c0de9dec01abca9d8ba/vscjava.vscode-maven -DoutputFileName=a9214f63b8d8500db2a00b0daf3718f9.deps.txt -X -f /Users/myuser/git/tmp/hello-world/pom.xml

Note the explicit /usr/bin/java invocation, which is 1.8 on my Mac. It seems VS Code (maven extension) does not configure the JVM properly - it is set to different one in the configuration. But I tested with other JVM versions using the same command - the problem is still reproducible with OpenJDK 11 and OpenJDK 18.

After playing with this command I found that the real game changer is "-DshowDuplicates" flag. If I remove it, the problem does not seem to occur. Oddly enough, VS Code console does not seem to show this flag being used but, as you said, it is actually being used.

Hope it helps.

tonjohn commented 2 years ago

@ngrigoriev just confirmed that -DshowDuplicates is the source of the problem. Thanks for the tip!

@ferstl unfortunately the project is private and NDA limits what I can share 😢