Open RalfNaujokat opened 1 month ago
Google took me to: https://stackoverflow.com/questions/71027480/java-exception-exception-java-lang-illegalargumentexception-comparison-method
and then to https://stackoverflow.com/questions/8327514/comparison-method-violates-its-general-contract
so finally starting as export MAVEN_OPTS="-Djava.util.Arrays.useLegacyMergeSort=true" ; mvn versions:display-dependency-updates
at least is a workaround.
Can you provide a minimal project (pom.xml) to run the goal on in order to reproduce the problem?
sorry, but i this happened only on one very big project with tons of dependencies. i have no clue which one triggers the error.
Does this happen with other Maven versions on this particular project?
Looking at the stack trace, it seems that it's an error within Resolver (so, Maven) rather than in the plugin itself. Compare especially:
Caused by: java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.ComparableTimSort.mergeHi (ComparableTimSort.java:870)
at java.util.ComparableTimSort.mergeAt (ComparableTimSort.java:487)
at java.util.ComparableTimSort.mergeForceCollapse (ComparableTimSort.java:426)
at java.util.ComparableTimSort.sort (ComparableTimSort.java:222)
at java.util.Arrays.sort (Arrays.java:1108)
at java.util.Arrays.sort (Arrays.java:1302)
at java.util.ArrayList.sort (ArrayList.java:1804)
at java.util.Collections.sort (Collections.java:145)
at org.apache.maven.repository.internal.DefaultVersionRangeResolver.resolveVersionRange (DefaultVersionRangeResolver.java:160)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveVersionRange (DefaultRepositorySystem.java:260)
at org.codehaus.mojo.versions.api.DefaultVersionsHelper.lookupArtifactVersions (DefaultVersionsHelper.java:282)
at org.codehaus.mojo.versions.api.DefaultVersionsHelper.lookupDependencyUpdates (DefaultVersionsHelper.java:553)
at org.codehaus.mojo.versions.api.DefaultVersionsHelper.lambda$lookupDependenciesUpdates$4 (DefaultVersionsHelper.java:522)
DefaultVersionRangeResolver::resolveVersionRange:
List<Version> versions = new ArrayList<>();
...
Collections.sort( versions ); <--------
So, it looks like GenericVersion::compareTo
might be the culprit here. To be checked
https://issues.apache.org/jira/browse/MRESOLVER-314 Resolved in Resolver 1.9.5 by maven-resolver#249
@RalfNaujokat please make sure that you're using Maven 3.9.1 or newer. Best if you could provide an (obfuscated, if necessary) output of mvn -X
running the goal.
Hi.
Sorry that i left you alone with that, i wasn't available over weekend. I was using Maven 3.9.9 when the error occurred.
I will try to reproduce the error and send you a mvn -X output, but to be honest, i'm not very confident that I can still manage that.
greetings Ralf
The issue is coming from Maven itself (we use provided
Maven dependencies in plugins), so if you're in fact using 3.9.9 then it's a yet another problem with the GenericVersion::compareTo
method. I would invite you to file a bug with Maven itself (project MRESOLVER in the Apache Jira).
The -X (debug) output of Maven will help verifying that. In particular, it's very important to check if there are no "unorthodox" version numbers among your dependency as that's where the comparator is having a problem with.
Using Maven 3.9.9 with different JDKs (Oracle Java 21, GraalVM 21/23) on Linux
StackTrace is:
` == BEGIN ==
[ERROR] Failed to execute goal org.codehaus.mojo:versions-maven-plugin:2.17.1:display-dependency-updates (default-cli) on project libraries: Unable to acquire metadata for dependencies java.util.stream.ReferencePipeline$2@629591d0: java.lang.IllegalArgumentException: Comparison method violates its general contract! -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:versions-maven-plugin:2.17.1:display-dependency-updates (default-cli) on project libraries: Unable to acquire metadata for dependencies java.util.stream.ReferencePipeline$2@629591d0: java.lang.IllegalArgumentException: Comparison method violates its general contract! at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:333) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174) at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75) at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162) at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105) at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:193) at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:180) at java.util.concurrent.FutureTask.run (FutureTask.java:317) at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:572) at java.util.concurrent.FutureTask.run (FutureTask.java:317) at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1144) at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:642) at java.lang.Thread.run (Thread.java:1583) Caused by: org.apache.maven.plugin.MojoExecutionException: Unable to acquire metadata for dependencies java.util.stream.ReferencePipeline$2@629591d0: java.lang.IllegalArgumentException: Comparison method violates its general contract! at org.codehaus.mojo.versions.DisplayDependencyUpdatesMojo.execute (DisplayDependencyUpdatesMojo.java:477) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174) at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75) at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162) at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105) at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:193) at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:180) at java.util.concurrent.FutureTask.run (FutureTask.java:317) at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:572) at java.util.concurrent.FutureTask.run (FutureTask.java:317) at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1144) at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:642) at java.lang.Thread.run (Thread.java:1583) Caused by: org.codehaus.mojo.versions.api.VersionRetrievalException: Unable to acquire metadata for dependencies java.util.stream.ReferencePipeline$2@629591d0: java.lang.IllegalArgumentException: Comparison method violates its general contract! at org.codehaus.mojo.versions.api.DefaultVersionsHelper.lookupDependenciesUpdates (DefaultVersionsHelper.java:533) at org.codehaus.mojo.versions.api.DefaultVersionsHelper.lookupDependenciesUpdates (DefaultVersionsHelper.java:543) at org.codehaus.mojo.versions.DisplayDependencyUpdatesMojo.execute (DisplayDependencyUpdatesMojo.java:412) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174) at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75) at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162) at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105) at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:193) at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:180) at java.util.concurrent.FutureTask.run (FutureTask.java:317) at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:572) at java.util.concurrent.FutureTask.run (FutureTask.java:317) at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1144) at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:642) at java.lang.Thread.run (Thread.java:1583) Caused by: java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Comparison method violates its general contract! at java.util.concurrent.FutureTask.report (FutureTask.java:122) at java.util.concurrent.FutureTask.get (FutureTask.java:191) at org.codehaus.mojo.versions.api.DefaultVersionsHelper.lookupDependenciesUpdates (DefaultVersionsHelper.java:526) at org.codehaus.mojo.versions.api.DefaultVersionsHelper.lookupDependenciesUpdates (DefaultVersionsHelper.java:543) at org.codehaus.mojo.versions.DisplayDependencyUpdatesMojo.execute (DisplayDependencyUpdatesMojo.java:412) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174) at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75) at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162) at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105) at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:193) at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:180) at java.util.concurrent.FutureTask.run (FutureTask.java:317) at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:572) at java.util.concurrent.FutureTask.run (FutureTask.java:317) at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1144) at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:642) at java.lang.Thread.run (Thread.java:1583) Caused by: java.lang.IllegalArgumentException: Comparison method violates its general contract! at java.util.ComparableTimSort.mergeHi (ComparableTimSort.java:870) at java.util.ComparableTimSort.mergeAt (ComparableTimSort.java:487) at java.util.ComparableTimSort.mergeForceCollapse (ComparableTimSort.java:426) at java.util.ComparableTimSort.sort (ComparableTimSort.java:222) at java.util.Arrays.sort (Arrays.java:1108) at java.util.Arrays.sort (Arrays.java:1302) at java.util.ArrayList.sort (ArrayList.java:1804) at java.util.Collections.sort (Collections.java:145) at org.apache.maven.repository.internal.DefaultVersionRangeResolver.resolveVersionRange (DefaultVersionRangeResolver.java:160) at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveVersionRange (DefaultRepositorySystem.java:260) at org.codehaus.mojo.versions.api.DefaultVersionsHelper.lookupArtifactVersions (DefaultVersionsHelper.java:282) at org.codehaus.mojo.versions.api.DefaultVersionsHelper.lookupDependencyUpdates (DefaultVersionsHelper.java:553) at org.codehaus.mojo.versions.api.DefaultVersionsHelper.lambda$lookupDependenciesUpdates$4 (DefaultVersionsHelper.java:522) at java.util.concurrent.FutureTask.run (FutureTask.java:317) at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1144) at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:642) at java.lang.Thread.run (Thread.java:1583)
== END == `