scholzb-hb opened a new issue, #463: URL: https://github.com/apache/maven-build-cache-extension/issues/463
### Affected version 1.2.2 ### Bug description In a certain scenario, the build may result in a cache miss although the required cache entry is available on the remote cache. The scenario is as follows (all builds on the same source code commit): 1. Build runner A runs a build with -DskipTests and saves the result in the remote cache 2. Build runner B runs a build with -DskipTests and loads the result from the remote cache (skipping the actual build) 3. Build runner A runs a build without -DskipTests. Cache entry is found, but considered incomplete since skipTests was enabled. Tests are executed, and the result is saved in the remote cache again (under the same checksum, now with skipTests=false). 4. Build runner B runs a build without -DskipTests. Now the bug can be observed. **Expected behavior** Build runner B should load the result from the remote cache (from step 3). Test execution should be skipped. **Actual behavior** Build runner B finds the downloaded cache entry from step 2 in its local cache and considers it as incomplete, without checking the remote cache. Tests are executed again. **Reproduce** The scenario can be reproduced with the attached demo project. [reproducer.zip](https://github.com/user-attachments/files/25804262/reproducer.zip) Prerequisites: Empty remote cache (Nexus 3) running under http://localhost:8081/repository/buildcache, settings.xml contains a corresponding entry like ``` <server> <id>buildcache</id> <username>ci</username> <password>password</password> </server> ``` Commands to execute in the "reproducer" directory: ``` rm -rf buildrunnerA_m2/build-cache rm -rf buildrunnerB_m2/build-cache mvn clean install -Dmaven.repo.local=buildrunnerA_m2/repository -Dmaven.build.cache.remote.save.enabled=true -f demo/pom.xml -DskipTests mvn clean install -Dmaven.repo.local=buildrunnerB_m2/repository -Dmaven.build.cache.remote.save.enabled=true -f demo/pom.xml -DskipTests mvn clean install -Dmaven.repo.local=buildrunnerA_m2/repository -Dmaven.build.cache.remote.save.enabled=true -f demo/pom.xml mvn clean install -Dmaven.repo.local=buildrunnerB_m2/repository -Dmaven.build.cache.remote.save.enabled=true -f demo/pom.xml ``` Result: ``` [INFO] Attempting to restore project com.example:demo from build cache [INFO] Downloaded build found by checksum b882441c46a44429 [INFO] Found cached build, restoring com.example:demo from cache by checksum b882441c46a44429 [INFO] Plugin parameter mismatch found. Parameter: skipTests, expected: true, actual: false [INFO] Mojo cached parameters mismatch with actual, forcing full project build. Mojo: surefire:test [INFO] A cached mojo is not consistent, continuing with non cached build ``` **Workaround (not feasible in production!)** Delete buildrunnerB_m2/build-cache/v1.1/com.example/demo/b882441c46a44429/buildcache before step 4. Now the behavior is as expected: -> ``` [INFO] Attempting to restore project com.example:demo from build cache [INFO] Downloading http://localhost:8081/repository/buildcache/v1.1/com.example/demo/b882441c46a44429/buildinfo.xml [INFO] Found cached build, restoring com.example:demo from cache by checksum b882441c46a44429 [INFO] Downloading http://localhost:8081/repository/buildcache/v1.1/com.example/demo/b882441c46a44429/demo.jar [INFO] Downloading http://localhost:8081/repository/buildcache/v1.1/com.example/demo/b882441c46a44429/demo-mvn-cache-ext-extra-output-1.zip ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
