You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Miguel Ortega (Jira)" <ji...@apache.org> on 2023/02/14 03:13:00 UTC

[jira] [Updated] (MBUILDCACHE-44) Running duplicate maven phase leads to IllegalStateException and cache miss

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

Miguel Ortega updated MBUILDCACHE-44:
-------------------------------------
    Description: 
When running maven with a duplicate maven goal like below (i'm aware that compile phase here is not necessary)
{code:java}
mvn compile test
{code}
the plugin seems to create a cache key that cause an error if i call.
{code:java}
mvn test
{code}
This will cause the following error:
{code:java}
[ERROR] Failed to restore project
java.lang.IllegalStateException: Duplicate key default-resources:resources:process-resources:maven-resources-plugin:org.apache.maven.plugins (attempted merging values org.apache.maven.buildcache.xml.build.CompletedExecution@1e1b061 and org.apache.maven.buildcache.xml.build.CompletedExecution@38f77cd9)  
    at java.util.stream.Collectors.duplicateKeyException (Collectors.java:135)
    at java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1 (Collectors.java:182)
    at java.util.stream.ReduceOps$3ReducingSink.accept (ReduceOps.java:169)
    at java.util.ArrayList$ArrayListSpliterator.forEachRemaining (ArrayList.java:1625)
    at java.util.stream.AbstractPipeline.copyInto (AbstractPipeline.java:509)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto (AbstractPipeline.java:499)
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential (ReduceOps.java:921)
    at java.util.stream.AbstractPipeline.evaluate (AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.collect (ReferencePipeline.java:682)
    at org.apache.maven.buildcache.xml.Build.getExecutionMap (Build.java:198)
    at org.apache.maven.buildcache.xml.Build.hasCompletedExecution (Build.java:116)
    at org.apache.maven.buildcache.xml.Build.lambda$getMissingExecutions$0 (Build.java:110)
    at java.util.stream.ReferencePipeline$2$1.accept (ReferencePipeline.java:178)
    at java.util.ArrayList$ArrayListSpliterator.forEachRemaining (ArrayList.java:1625)
    at java.util.stream.AbstractPipeline.copyInto (AbstractPipeline.java:509)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto (AbstractPipeline.java:499)
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential (ReduceOps.java:921)
    at java.util.stream.AbstractPipeline.evaluate (AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.collect (ReferencePipeline.java:682)
    at org.apache.maven.buildcache.xml.Build.getMissingExecutions (Build.java:111)
    at org.apache.maven.buildcache.CacheControllerImpl.analyzeResult (CacheControllerImpl.java:267)
    at org.apache.maven.buildcache.CacheControllerImpl.findLocalBuild (CacheControllerImpl.java:234)
    at org.apache.maven.buildcache.CacheControllerImpl.findCachedBuild (CacheControllerImpl.java:185)
    at org.apache.maven.buildcache.BuildCacheMojosExecutionStrategy.execute (BuildCacheMojosExecutionStrategy.java:114)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:160)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:260)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:172)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:100)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:821)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:270)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
 {code}
The source problem seems to be that method "buildExecutionInfo" can return a list with duplicate "CompletedExecution " (same execution key)

Steps to reproduce:
 * From a simple maven project (repo project attached), with clean cache, run duplicate phase `mvn compile test`
 * Then run `mvn test`
 *  -> An exception is thown and no cache is used
 * Running either of the commands again work as expected

Expected Behaviour:

Even in case of wrong user input like in this example, i guess i would expect:
 * A cache to not throw exception an reuse the 'test' cache from the first command
 * Or a more explicit error to explain severity or resolution to the user

Environment:
{noformat}
Apache Maven 3.9.0 (9b58d2bad23a66be161c4664ef21ce219c2c8584)
Maven home: <REDACTED>
Java version: 17.0.1, vendor: Eclipse Adoptium, runtime: C:\<REDACTED>\jdk-17.0.1.12-hotspot
Default locale: fr_FR, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"{noformat}

  was:
When running maven with a duplicate maven goal like below (i'm aware that compile phase here is not necessary)

 
{code:java}
mvn compile test
{code}
the plugin seems to create a cache key that cause an error if i call.

 

 
{code:java}
mvn test
{code}
This will cause the following error:

 

 
{code:java}
[ERROR] Failed to restore project
java.lang.IllegalStateException: Duplicate key default-resources:resources:process-resources:maven-resources-plugin:org.apache.maven.plugins (attempted merging values org.apache.maven.buildcache.xml.build.CompletedExecution@1e1b061 and org.apache.maven.buildcache.xml.build.CompletedExecution@38f77cd9)  
    at java.util.stream.Collectors.duplicateKeyException (Collectors.java:135)
    at java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1 (Collectors.java:182)
    at java.util.stream.ReduceOps$3ReducingSink.accept (ReduceOps.java:169)
    at java.util.ArrayList$ArrayListSpliterator.forEachRemaining (ArrayList.java:1625)
    at java.util.stream.AbstractPipeline.copyInto (AbstractPipeline.java:509)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto (AbstractPipeline.java:499)
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential (ReduceOps.java:921)
    at java.util.stream.AbstractPipeline.evaluate (AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.collect (ReferencePipeline.java:682)
    at org.apache.maven.buildcache.xml.Build.getExecutionMap (Build.java:198)
    at org.apache.maven.buildcache.xml.Build.hasCompletedExecution (Build.java:116)
    at org.apache.maven.buildcache.xml.Build.lambda$getMissingExecutions$0 (Build.java:110)
    at java.util.stream.ReferencePipeline$2$1.accept (ReferencePipeline.java:178)
    at java.util.ArrayList$ArrayListSpliterator.forEachRemaining (ArrayList.java:1625)
    at java.util.stream.AbstractPipeline.copyInto (AbstractPipeline.java:509)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto (AbstractPipeline.java:499)
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential (ReduceOps.java:921)
    at java.util.stream.AbstractPipeline.evaluate (AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.collect (ReferencePipeline.java:682)
    at org.apache.maven.buildcache.xml.Build.getMissingExecutions (Build.java:111)
    at org.apache.maven.buildcache.CacheControllerImpl.analyzeResult (CacheControllerImpl.java:267)
    at org.apache.maven.buildcache.CacheControllerImpl.findLocalBuild (CacheControllerImpl.java:234)
    at org.apache.maven.buildcache.CacheControllerImpl.findCachedBuild (CacheControllerImpl.java:185)
    at org.apache.maven.buildcache.BuildCacheMojosExecutionStrategy.execute (BuildCacheMojosExecutionStrategy.java:114)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:160)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:260)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:172)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:100)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:821)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:270)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
 {code}
 

 

Steps to reproduce:
 * From a simple maven project (repo project attached), with clean cache, run duplicate phase `mvn compile test`
 * Then run `mvn test`
 *  -> An exception is thown and no cache is used
 * Running either of the commands again work as expected

Expected Behaviour:

Even in case of wrong user input like in this example, i guess i would expect:
 * A cache to not throw exception an reuse the 'test' cache from the first command
 * Or a more explicit error to explain severity or resolution to the user

Environment:
{noformat}
Apache Maven 3.9.0 (9b58d2bad23a66be161c4664ef21ce219c2c8584)
Maven home: <REDACTED>
Java version: 17.0.1, vendor: Eclipse Adoptium, runtime: C:\<REDACTED>\jdk-17.0.1.12-hotspot
Default locale: fr_FR, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"{noformat}


> Running duplicate maven phase leads to IllegalStateException and cache miss
> ---------------------------------------------------------------------------
>
>                 Key: MBUILDCACHE-44
>                 URL: https://issues.apache.org/jira/browse/MBUILDCACHE-44
>             Project: Maven Build Cache Extension
>          Issue Type: Bug
>    Affects Versions: 1.0.0
>            Reporter: Miguel Ortega
>            Priority: Minor
>         Attachments: maven-cache.zip
>
>
> When running maven with a duplicate maven goal like below (i'm aware that compile phase here is not necessary)
> {code:java}
> mvn compile test
> {code}
> the plugin seems to create a cache key that cause an error if i call.
> {code:java}
> mvn test
> {code}
> This will cause the following error:
> {code:java}
> [ERROR] Failed to restore project
> java.lang.IllegalStateException: Duplicate key default-resources:resources:process-resources:maven-resources-plugin:org.apache.maven.plugins (attempted merging values org.apache.maven.buildcache.xml.build.CompletedExecution@1e1b061 and org.apache.maven.buildcache.xml.build.CompletedExecution@38f77cd9)  
>     at java.util.stream.Collectors.duplicateKeyException (Collectors.java:135)
>     at java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1 (Collectors.java:182)
>     at java.util.stream.ReduceOps$3ReducingSink.accept (ReduceOps.java:169)
>     at java.util.ArrayList$ArrayListSpliterator.forEachRemaining (ArrayList.java:1625)
>     at java.util.stream.AbstractPipeline.copyInto (AbstractPipeline.java:509)
>     at java.util.stream.AbstractPipeline.wrapAndCopyInto (AbstractPipeline.java:499)
>     at java.util.stream.ReduceOps$ReduceOp.evaluateSequential (ReduceOps.java:921)
>     at java.util.stream.AbstractPipeline.evaluate (AbstractPipeline.java:234)
>     at java.util.stream.ReferencePipeline.collect (ReferencePipeline.java:682)
>     at org.apache.maven.buildcache.xml.Build.getExecutionMap (Build.java:198)
>     at org.apache.maven.buildcache.xml.Build.hasCompletedExecution (Build.java:116)
>     at org.apache.maven.buildcache.xml.Build.lambda$getMissingExecutions$0 (Build.java:110)
>     at java.util.stream.ReferencePipeline$2$1.accept (ReferencePipeline.java:178)
>     at java.util.ArrayList$ArrayListSpliterator.forEachRemaining (ArrayList.java:1625)
>     at java.util.stream.AbstractPipeline.copyInto (AbstractPipeline.java:509)
>     at java.util.stream.AbstractPipeline.wrapAndCopyInto (AbstractPipeline.java:499)
>     at java.util.stream.ReduceOps$ReduceOp.evaluateSequential (ReduceOps.java:921)
>     at java.util.stream.AbstractPipeline.evaluate (AbstractPipeline.java:234)
>     at java.util.stream.ReferencePipeline.collect (ReferencePipeline.java:682)
>     at org.apache.maven.buildcache.xml.Build.getMissingExecutions (Build.java:111)
>     at org.apache.maven.buildcache.CacheControllerImpl.analyzeResult (CacheControllerImpl.java:267)
>     at org.apache.maven.buildcache.CacheControllerImpl.findLocalBuild (CacheControllerImpl.java:234)
>     at org.apache.maven.buildcache.CacheControllerImpl.findCachedBuild (CacheControllerImpl.java:185)
>     at org.apache.maven.buildcache.BuildCacheMojosExecutionStrategy.execute (BuildCacheMojosExecutionStrategy.java:114)
>     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:160)
>     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
>     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
>     at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
>     at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
>     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:260)
>     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:172)
>     at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:100)
>     at org.apache.maven.cli.MavenCli.execute (MavenCli.java:821)
>     at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:270)
>     at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
>     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
>     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
>     at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
>     at java.lang.reflect.Method.invoke (Method.java:568)
>     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
>     at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
>     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
>     at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
>  {code}
> The source problem seems to be that method "buildExecutionInfo" can return a list with duplicate "CompletedExecution " (same execution key)
> Steps to reproduce:
>  * From a simple maven project (repo project attached), with clean cache, run duplicate phase `mvn compile test`
>  * Then run `mvn test`
>  *  -> An exception is thown and no cache is used
>  * Running either of the commands again work as expected
> Expected Behaviour:
> Even in case of wrong user input like in this example, i guess i would expect:
>  * A cache to not throw exception an reuse the 'test' cache from the first command
>  * Or a more explicit error to explain severity or resolution to the user
> Environment:
> {noformat}
> Apache Maven 3.9.0 (9b58d2bad23a66be161c4664ef21ce219c2c8584)
> Maven home: <REDACTED>
> Java version: 17.0.1, vendor: Eclipse Adoptium, runtime: C:\<REDACTED>\jdk-17.0.1.12-hotspot
> Default locale: fr_FR, platform encoding: Cp1252
> OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"{noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)