[
https://issues.apache.org/jira/browse/MBUILDCACHE-44?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17703546#comment-17703546
]
ASF GitHub Bot commented on MBUILDCACHE-44:
-------------------------------------------
eltsovalex opened a new pull request, #52:
URL: https://github.com/apache/maven-build-cache-extension/pull/52
Reproduced the issue with an integration test, applied a fix (via
deduplication of info of executions) and created a test that proves issue is
now gone.
Following this checklist to help us incorporate your
contribution quickly and easily:
- [ ] Make sure there is a [JIRA
issue](https://issues.apache.org/jira/browse/MNG) filed
for the change (usually before you start working on it). Trivial
changes like typos do not
require a JIRA issue. Your pull request should address just this
issue, without
pulling in other changes.
- [ ] Each commit in the pull request should have a meaningful subject line
and body.
- [ ] Format the pull request title like `[MNG-XXX] - Fixes bug in
ApproximateQuantiles`,
where you replace `MNG-XXX` with the appropriate JIRA issue. Best
practice
is to use the JIRA issue title in the pull request title and in the
first line of the
commit message.
- [ ] Write a pull request description that is detailed enough to
understand what the pull request does, how, and why.
- [ ] Run `mvn clean verify` to make sure basic checks pass. A more
thorough check will
be performed on your pull request automatically.
- [ ] You have run the [Core IT][core-its] successfully.
If your pull request is about ~20 lines of code you don't need to sign an
[Individual Contributor License
Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the [Apache License Version 2.0, January
2004](http://www.apache.org/licenses/LICENSE-2.0)
you have to acknowledge this by using the following check-box.
- [ ] I hereby declare this contribution to be licenced under the [Apache
License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
- [ ] In any other case, please file an [Apache Individual Contributor
License Agreement](https://www.apache.org/licenses/icla.pdf).
[core-its]: https://maven.apache.org/core-its/core-it-suite/
> 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}
>
> *+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}
> +*Suggested source problem & fix*+
> The source problem seems to be that method "buildExecutionInfo" can return a
> list with duplicate "CompletedExecution" (same execution key)
> My suggested fix would be to either to deduplicate the "CompletedExecution" by
> "executionKey" CacheControllerImpl.buildExecutionInfo or change the unicity
> key for
> CompletedExecution.
> I could work on a PR if bug is confirmed and suggested fix is validated.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)