Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<task> --rerun fails on configuration cache hit #21748

Closed
abstratt opened this issue Aug 30, 2022 · 0 comments
Closed

<task> --rerun fails on configuration cache hit #21748

abstratt opened this issue Aug 30, 2022 · 0 comments

Comments

@abstratt
Copy link
Member

abstratt commented Aug 30, 2022

Expected Behavior

No error produced when using the --rerun option with configuration cache enabled.

Current Behavior

Running a Gradle task with the new --rerun option will break on a configuration cache hit.

Context

The new --rerun option implemented in 7.6 (by yours truly) was not tested with configuration cache enabled, but it clearly does not work.

This seems similar to #20296 (in a sense that could benefit from a similar workaround - using using a non-anonymous type implementing a SAM interface instance instead of a lambda, as per docs) or #21109, more specifically for this lambda in OptionReader BUILT_IN_OPTIONS.

Steps to Reproduce

  1. Make sure you are using a more or less recent 7.6 snapshot build. I used:

distributionUrl=https://services.gradle.org/distributions-snapshots/gradle-7.6-20220830021557+0000-bin.zip

  1. Issue the following command:

./gradlew help --configuration-cache --rerun

which succeeds. But a second call (configuration cache hit) fails:

  1. Issue the same command again:

./gradlew help --configuration-cache --rerun

results in:

Configuration cache is an incubating feature.
Reusing configuration cache.

FAILURE: Build failed with an exception.

* What went wrong:
Could not load the value of field `specs` of `org.gradle.api.specs.AndSpec` bean found in task `:help` of type `org.gradle.configuration.Help`.
> org.gradle.api.internal.tasks.options.OptionReader$$Lambda$1125/0x000000080095b440

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

CONFIGURE FAILED in 397ms

Publishing build scan...
https://e.grdev.net/s/nmvg6nbfsqkg2

Configuration cache entry reused.

Stacktrace:

Caused by: java.lang.ClassNotFoundException: org.gradle.api.internal.tasks.options.OptionReader$$Lambda$1125/0x000000080095b440	
at org.gradle.configurationcache.serialization.DefaultReadContext.readClass(Contexts.kt:285)	
at org.gradle.configurationcache.serialization.codecs.BeanCodec.decode(BeanCodec.kt:44)	
at org.gradle.configurationcache.serialization.CombinatorsKt$reentrant$1$decodeLoop$1.invokeSuspend(Combinators.kt:165)	
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)	
at kotlin.coroutines.ContinuationKt.startCoroutine(Continuation.kt:115)	
at org.gradle.configurationcache.serialization.CombinatorsKt$reentrant$1.decodeLoop(Combinators.kt:166)	
at org.gradle.configurationcache.serialization.CombinatorsKt$reentrant$1.decode(Combinators.kt:130)	
at org.gradle.configurationcache.serialization.codecs.BindingsBackedCodec.decode(BindingsBackedCodec.kt:59)	
at org.gradle.configurationcache.serialization.DefaultReadContext.read(Contexts.kt:259)	
at org.gradle.configurationcache.serialization.CodecKt.readNonNull(Codec.kt:96)	
at org.gradle.configurationcache.serialization.codecs.TaskNodeCodec.readUpToDateSpec(TaskNodeCodec.kt:153)	
at org.gradle.configurationcache.serialization.codecs.TaskNodeCodec.access$readUpToDateSpec(TaskNodeCodec.kt:64)	
at org.gradle.configurationcache.serialization.codecs.TaskNodeCodec$readTask$2.invokeSuspend(TaskNodeCodec.kt:123)	
at org.gradle.configurationcache.serialization.codecs.TaskNodeCodec$readTask$2.invoke(TaskNodeCodec.kt)	
at org.gradle.configurationcache.serialization.codecs.TaskNodeCodec$readTask$2.invoke(TaskNodeCodec.kt)	
at org.gradle.configurationcache.serialization.codecs.TaskNodeCodecKt.withTaskOf(TaskNodeCodec.kt:230)	
at org.gradle.configurationcache.serialization.codecs.TaskNodeCodecKt.access$withTaskOf(TaskNodeCodec.kt:1)	
at org.gradle.configurationcache.serialization.codecs.TaskNodeCodec.readTask(TaskNodeCodec.kt:122)	
at org.gradle.configurationcache.serialization.codecs.TaskNodeCodec.decode(TaskNodeCodec.kt:75)	
at org.gradle.configurationcache.serialization.codecs.BindingsBackedCodec.decode(BindingsBackedCodec.kt:59)	
at org.gradle.configurationcache.serialization.DefaultReadContext.read(Contexts.kt:259)	
at org.gradle.configurationcache.serialization.CodecKt.readNonNull(Codec.kt:96)	
at org.gradle.configurationcache.serialization.codecs.WorkNodeCodec.readNode(WorkNodeCodec.kt:96)	
at org.gradle.configurationcache.serialization.codecs.WorkNodeCodec.readNodes(WorkNodeCodec.kt:83)	
at org.gradle.configurationcache.serialization.codecs.WorkNodeCodec.readWork(WorkNodeCodec.kt:59)	
at org.gradle.configurationcache.ConfigurationCacheState.readWorkGraph(ConfigurationCacheState.kt:262)	
at org.gradle.configurationcache.ConfigurationCacheState.readBuildState$configuration_cache(ConfigurationCacheState.kt:234)	
at org.gradle.configurationcache.ConfigurationCacheState.readRootBuild(ConfigurationCacheState.kt:191)	
at org.gradle.configurationcache.ConfigurationCacheState.readRootBuildState(ConfigurationCacheState.kt:119)
...

A similar issue happens with any other task, for instance:

./gradlew tasks --configuration-cache --rerun

Your Environment

MacOS
Gradle 7.6 and 7.7

Build scan URL:
https://e.grdev.net/s/nmvg6nbfsqkg2

@abstratt abstratt self-assigned this Sep 1, 2022
abstratt added a commit that referenced this issue Sep 1, 2022
The configuration cache chokes on non-serializable lambdas.
This works around that issue by using a serializable spec.

Issue: #21748
@abstratt abstratt added this to the 7.6 RC1 milestone Sep 1, 2022
abstratt added a commit that referenced this issue Sep 1, 2022
The configuration cache chokes on non-serializable lambdas.
This works around that issue by using a serializable spec.

Issue: #21748
bot-gradle added a commit that referenced this issue Sep 1, 2022
The configuration cache chokes on non-serializable lambdas.
This works around that issue by using a serializable spec.

Issue: #21748

Co-authored-by: Rafael Chaves <rchaves@gradle.com>
@bamboo bamboo closed this as completed Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants