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

Configuration cache failure 7.0.0BETA4 / Gradle 8.12 w/ custom prettier step #2372

Open
cloudshiftchris opened this issue Dec 21, 2024 · 3 comments
Labels

Comments

@cloudshiftchris
Copy link

Spotless task fails when running with a custom prettier step:

spotless {
    format("webapp") {
        target("src/**/*.scss", "src/**/*.css", "src/**/*.html", "src/**/*.ts")
        prettier()
    }
}

This is the exception:

* Exception is:
org.gradle.api.GradleException: Could not load the value of field `additionalNpmrcLocations` of `com.diffplug.spotless.npm.NpmPathResolver` bean found in field `resolver` of `com.diffplug.spotless.npm.NpmFormatterStepLocations` bean found in field `locations` of `com.diffplug.spotless.npm.PrettierFormatterStep$State` bean found in field `equalityStateInternal` of `com.diffplug.spotless.FormatterStepSerializationRoundtrip` bean found in field `cleaned` of `com.diffplug.spotless.FormatterStepSerializationRoundtrip$HackClone` bean found in field `backingList` of `com.diffplug.spotless.ConfigurationCacheHackList` bean found in field `stepsInternalEquality` of task `:webui:spotlessWebapp` of type `com.diffplug.gradle.spotless.SpotlessTaskImpl`.
        at org.gradle.internal.serialize.graph.BeanPropertyExtensionsKt.readPropertyValue(BeanPropertyExtensions.kt:68)
        at org.gradle.internal.serialize.beans.services.BeanPropertyReader.readFieldOf(BeanPropertyReader.kt:90)
        at org.gradle.internal.serialize.beans.services.BeanPropertyReader.readFieldsOf(BeanPropertyReader.kt:72)
        at org.gradle.internal.serialize.beans.services.BeanPropertyReader.readStateOf(BeanPropertyReader.kt:65)
        at org.gradle.internal.serialize.graph.codecs.BeanCodec.readBeanOf(BeanCodec.kt:61)
        at org.gradle.internal.serialize.graph.codecs.BeanCodec.decode(BeanCodec.kt:43)
        at org.gradle.internal.serialize.graph.CombinatorsKt$reentrant$1.decode(Combinators.kt:80)
        at org.gradle.internal.serialize.graph.codecs.BindingsBackedCodec.decode(BindingsBackedCodec.kt:70)
        at org.gradle.internal.serialize.graph.DefaultReadContext.read(Contexts.kt:279)
        at org.gradle.internal.serialize.graph.BeanPropertyExtensionsKt.readPropertyValue(BeanPropertyExtensions.kt:61)
        at org.gradle.internal.serialize.beans.services.BeanPropertyReader.readFieldOf(BeanPropertyReader.kt:90)
        at org.gradle.internal.serialize.beans.services.BeanPropertyReader.readFieldsOf(BeanPropertyReader.kt:72)
        at org.gradle.internal.serialize.beans.services.BeanPropertyReader.readStateOf(BeanPropertyReader.kt:65)
        at org.gradle.internal.serialize.graph.codecs.BeanCodec.readBeanOf(BeanCodec.kt:61)
        at org.gradle.internal.serialize.graph.codecs.BeanCodec.decode(BeanCodec.kt:43)
        at org.gradle.internal.serialize.graph.CombinatorsKt$reentrant$1.decode(Combinators.kt:80)
        at org.gradle.internal.serialize.graph.codecs.BindingsBackedCodec.decode(BindingsBackedCodec.kt:70)
        at org.gradle.internal.serialize.graph.DefaultReadContext.read(Contexts.kt:279)
        at org.gradle.internal.serialize.graph.BeanPropertyExtensionsKt.readPropertyValue(BeanPropertyExtensions.kt:61)
        at org.gradle.internal.serialize.beans.services.BeanPropertyReader.readFieldOf(BeanPropertyReader.kt:90)
        at org.gradle.internal.serialize.beans.services.BeanPropertyReader.readFieldsOf(BeanPropertyReader.kt:72)
        at org.gradle.internal.serialize.beans.services.BeanPropertyReader.readStateOf(BeanPropertyReader.kt:65)
        at org.gradle.internal.serialize.graph.codecs.BeanCodec.readBeanOf(BeanCodec.kt:61)
        at org.gradle.internal.serialize.graph.codecs.BeanCodec.decode(BeanCodec.kt:43)
        at org.gradle.internal.serialize.graph.CombinatorsKt$reentrant$1.decode(Combinators.kt:80)
        at org.gradle.internal.serialize.graph.codecs.BindingsBackedCodec.decode(BindingsBackedCodec.kt:70)
        at org.gradle.internal.serialize.graph.DefaultReadContext.read(Contexts.kt:279)
        at org.gradle.internal.serialize.graph.BeanPropertyExtensionsKt.readPropertyValue(BeanPropertyExtensions.kt:61)
        at org.gradle.internal.serialize.beans.services.BeanPropertyReader.readFieldOf(BeanPropertyReader.kt:90)
        at org.gradle.internal.serialize.beans.services.BeanPropertyReader.readFieldsOf(BeanPropertyReader.kt:72)
        at org.gradle.internal.serialize.beans.services.BeanPropertyReader.readStateOf(BeanPropertyReader.kt:65)
        at org.gradle.internal.serialize.codecs.core.jos.ObjectInputStreamAdapter$defaultReadObject$1$1.invokeSuspend(ObjectInputStreamAdapter.kt:47)
        at org.gradle.internal.serialize.codecs.core.jos.ObjectInputStreamAdapter$defaultReadObject$1$1.invoke(ObjectInputStreamAdapter.kt)
        at org.gradle.internal.serialize.codecs.core.jos.ObjectInputStreamAdapter$defaultReadObject$1$1.invoke(ObjectInputStreamAdapter.kt)
        at org.gradle.internal.serialize.graph.RunningKt$runReadOperation$2.invokeSuspend(Running.kt:33)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlin.coroutines.ContinuationKt.startCoroutine(Continuation.kt:115)
        at org.gradle.internal.serialize.graph.RunningKt.runToCompletion(Running.kt:54)
        at org.gradle.internal.serialize.graph.RunningKt.runReadOperation(Running.kt:32)
        at org.gradle.internal.serialize.codecs.core.jos.ObjectInputStreamAdapter.defaultReadObject(ObjectInputStreamAdapter.kt:46)
        at org.gradle.internal.serialize.codecs.core.jos.JavaObjectSerializationCodec.decode(JavaObjectSerializationCodec.kt:92)
        at org.gradle.internal.serialize.graph.codecs.BindingsBackedCodec.decode(BindingsBackedCodec.kt:70)
        at org.gradle.internal.serialize.graph.DefaultReadContext.read(Contexts.kt:279)
        at org.gradle.internal.serialize.graph.BeanPropertyExtensionsKt.readPropertyValue(BeanPropertyExtensions.kt:61)
        at org.gradle.internal.serialize.beans.services.BeanPropertyReader.readFieldOf(BeanPropertyReader.kt:90)
        at org.gradle.internal.serialize.beans.services.BeanPropertyReader.readFieldsOf(BeanPropertyReader.kt:72)
        at org.gradle.internal.serialize.beans.services.BeanPropertyReader.readStateOf(BeanPropertyReader.kt:65)
        at org.gradle.internal.serialize.codecs.core.jos.ObjectInputStreamAdapter$defaultReadObject$1$1.invokeSuspend(ObjectInputStreamAdapter.kt:47)
        at org.gradle.internal.serialize.codecs.core.jos.ObjectInputStreamAdapter$defaultReadObject$1$1.invoke(ObjectInputStreamAdapter.kt)
        at org.gradle.internal.serialize.codecs.core.jos.ObjectInputStreamAdapter$defaultReadObject$1$1.invoke(ObjectInputStreamAdapter.kt)
        at org.gradle.internal.serialize.graph.RunningKt$runReadOperation$2.invokeSuspend(Running.kt:33)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlin.coroutines.ContinuationKt.startCoroutine(Continuation.kt:115)
        at org.gradle.internal.serialize.graph.RunningKt.runToCompletion(Running.kt:54)
        at org.gradle.internal.serialize.graph.RunningKt.runReadOperation(Running.kt:32)
        at org.gradle.internal.serialize.codecs.core.jos.ObjectInputStreamAdapter.defaultReadObject(ObjectInputStreamAdapter.kt:46)
        at org.gradle.internal.serialize.codecs.core.jos.JavaObjectSerializationCodec.decode(JavaObjectSerializationCodec.kt:92)
        at org.gradle.internal.serialize.graph.codecs.BindingsBackedCodec.decode(BindingsBackedCodec.kt:70)
        at org.gradle.internal.serialize.graph.DefaultReadContext.read(Contexts.kt:279)
        at org.gradle.internal.serialize.graph.CombinatorsKt.readCollectionInto(Combinators.kt:189)
        at org.gradle.internal.serialize.codecs.stdlib.CollectionCodecsKt$collectionCodec$2.invokeSuspend(CollectionCodecs.kt:81)
        at org.gradle.internal.serialize.codecs.stdlib.CollectionCodecsKt$collectionCodec$2.invoke(CollectionCodecs.kt)
        at org.gradle.internal.serialize.codecs.stdlib.CollectionCodecsKt$collectionCodec$2.invoke(CollectionCodecs.kt)
        at org.gradle.internal.serialize.graph.CombinatorsKt$codec$1.decode(Combinators.kt:44)
        at org.gradle.internal.serialize.graph.codecs.BindingsBackedCodec.decode(BindingsBackedCodec.kt:70)
        at org.gradle.internal.serialize.graph.DefaultReadContext.read(Contexts.kt:279)
        at org.gradle.internal.serialize.graph.BeanPropertyExtensionsKt.readPropertyValue(BeanPropertyExtensions.kt:61)
        at org.gradle.internal.serialize.beans.services.BeanPropertyReader.readFieldOf(BeanPropertyReader.kt:90)
        at org.gradle.internal.serialize.beans.services.BeanPropertyReader.readFieldsOf(BeanPropertyReader.kt:72)
        at org.gradle.internal.serialize.beans.services.BeanPropertyReader.readStateOf(BeanPropertyReader.kt:65)
        at org.gradle.internal.serialize.graph.codecs.BeanCodec.readBeanOf(BeanCodec.kt:61)
        at org.gradle.internal.serialize.graph.codecs.BeanCodec.decode(BeanCodec.kt:43)
        at org.gradle.internal.serialize.graph.CombinatorsKt$reentrant$1$decodeLoop$1.invokeSuspend(Combinators.kt:122)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlin.coroutines.ContinuationKt.startCoroutine(Continuation.kt:115)
        at org.gradle.internal.serialize.graph.CombinatorsKt$reentrant$1.decodeLoop(Combinators.kt:123)
        at org.gradle.internal.serialize.graph.CombinatorsKt$reentrant$1.decode(Combinators.kt:85)
        at org.gradle.internal.serialize.graph.codecs.BindingsBackedCodec.decode(BindingsBackedCodec.kt:70)
        at org.gradle.internal.serialize.graph.DefaultReadContext.read(Contexts.kt:279)
        at org.gradle.internal.serialize.graph.BeanPropertyExtensionsKt.readPropertyValue(BeanPropertyExtensions.kt:61)
        at org.gradle.internal.serialize.beans.services.BeanPropertyReader.readFieldOf(BeanPropertyReader.kt:90)
        at org.gradle.internal.serialize.beans.services.BeanPropertyReader.readFieldsOf(BeanPropertyReader.kt:72)
        at org.gradle.internal.serialize.beans.services.BeanPropertyReader.readStateOf(BeanPropertyReader.kt:65)
        at org.gradle.internal.serialize.codecs.core.TaskNodeCodec$readTask$2.invokeSuspend(TaskNodeCodec.kt:134)
        at org.gradle.internal.serialize.codecs.core.TaskNodeCodec$readTask$2.invoke(TaskNodeCodec.kt)
        at org.gradle.internal.serialize.codecs.core.TaskNodeCodec$readTask$2.invoke(TaskNodeCodec.kt)
        at org.gradle.internal.serialize.codecs.core.TaskNodeCodecKt.withTaskOf(TaskNodeCodec.kt:236)
        at org.gradle.internal.serialize.codecs.core.TaskNodeCodecKt.access$withTaskOf(TaskNodeCodec.kt:1)
        at org.gradle.internal.serialize.codecs.core.TaskNodeCodec.readTask(TaskNodeCodec.kt:128)
        at org.gradle.internal.serialize.codecs.core.TaskNodeCodec.decode(TaskNodeCodec.kt:79)
        at org.gradle.internal.serialize.graph.codecs.BindingsBackedCodec.decode(BindingsBackedCodec.kt:70)
        at org.gradle.internal.serialize.graph.DefaultReadContext.read(Contexts.kt:279)
        at org.gradle.internal.serialize.graph.CodecKt.readNonNull(Codec.kt:156)
        at org.gradle.internal.serialize.codecs.core.WorkNodeCodec.readNode(WorkNodeCodec.kt:405)
        at org.gradle.internal.serialize.codecs.core.WorkNodeCodec.readGroupedNodes(WorkNodeCodec.kt:347)
        at org.gradle.internal.serialize.codecs.core.WorkNodeCodec.access$readGroupedNodes(WorkNodeCodec.kt:81)
        at org.gradle.internal.serialize.codecs.core.WorkNodeCodec$readNodes$1$1$1$1.invokeSuspend(WorkNodeCodec.kt:252)
        at org.gradle.internal.serialize.codecs.core.WorkNodeCodec$readNodes$1$1$1$1.invoke(WorkNodeCodec.kt)
        at org.gradle.internal.serialize.codecs.core.WorkNodeCodec$readNodes$1$1$1$1.invoke(WorkNodeCodec.kt)
        at org.gradle.internal.serialize.graph.CodecKt$readWith$1$1.invokeSuspend(Codec.kt:144)
        at org.gradle.internal.serialize.graph.CodecKt$readWith$1$1.invoke(Codec.kt)
        at org.gradle.internal.serialize.graph.CodecKt$readWith$1$1.invoke(Codec.kt)
        at org.gradle.internal.serialize.graph.RunningKt$runReadOperation$2.invokeSuspend(Running.kt:33)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlin.coroutines.ContinuationKt.startCoroutine(Continuation.kt:115)
        at org.gradle.internal.serialize.graph.RunningKt.runToCompletion(Running.kt:54)
        at org.gradle.internal.serialize.graph.RunningKt.runReadOperation(Running.kt:32)
        at org.gradle.internal.serialize.graph.CodecKt.readWith(Codec.kt:143)
        at org.gradle.internal.serialize.codecs.core.WorkNodeCodec$readNodes$1$1$1.invoke(WorkNodeCodec.kt:251)
        at org.gradle.internal.serialize.codecs.core.WorkNodeCodec$readNodes$1$1$1.invoke(WorkNodeCodec.kt:250)
        at org.gradle.internal.serialize.codecs.core.WorkNodeCodecKt$asBuildOperation$1.run(WorkNodeCodec.kt:634)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:166)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$QueueWorker.execute(DefaultBuildOperationExecutor.java:161)
        at org.gradle.internal.operations.DefaultBuildOperationQueue$WorkerRunnable.runOperation(DefaultBuildOperationQueue.java:272)
        at org.gradle.internal.operations.DefaultBuildOperationQueue$WorkerRunnable.doRunBatch(DefaultBuildOperationQueue.java:253)
        at org.gradle.internal.operations.DefaultBuildOperationQueue$WorkerRunnable.lambda$runBatch$1(DefaultBuildOperationQueue.java:226)
        at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:263)
        at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:127)
        at org.gradle.internal.operations.DefaultBuildOperationQueue$WorkerRunnable.runBatch(DefaultBuildOperationQueue.java:224)
        at org.gradle.internal.operations.DefaultBuildOperationQueue$WorkerRunnable.run(DefaultBuildOperationQueue.java:192)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
        at org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:48)
Caused by: java.io.InvalidObjectException: null array
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at org.gradle.internal.serialize.codecs.core.jos.JavaObjectSerializationCodec.readResolve(JavaObjectSerializationCodec.kt:197)
        at org.gradle.internal.serialize.codecs.core.jos.JavaObjectSerializationCodec.decode(JavaObjectSerializationCodec.kt:111)
        at org.gradle.internal.serialize.graph.codecs.BindingsBackedCodec.decode(BindingsBackedCodec.kt:70)
        at org.gradle.internal.serialize.graph.DefaultReadContext.read(Contexts.kt:279)
        at org.gradle.internal.serialize.graph.BeanPropertyExtensionsKt.readPropertyValue(BeanPropertyExtensions.kt:61)
        ... 124 more

Running with --no-configuration-cache works.

Gradle 8.12 / MacOS / Java 21 / Spotless 7.0.0BETA4 / Prettier 3.4.2

@jGleitz
Copy link

jGleitz commented Jan 8, 2025

I had a look into this issue and found the following:

  1. The exception is thrown by java.util.ImmutableCollections.CollSer, which is the serialization proxy used for Java’s immutable collections.
  2. #readResolve in CollSer throws because CollSer.array is null. It’s supposed to contain the array of elements which have been de-serialised.
  3. The CollSer.array hasn’t been deserialised (and probably never even been serialised) because it’s not listed in Gradle’s BeanPropertyReader.relevantFields
  4. CollSer.array isn’t considered relevant by Gradle because it is transient and Gradle doesn’t consider any transient field relevant.

I’m not sure what to make of this. It seems correct to me that Gradle ignores all transient fields. It seems weird to me that CollSer.array is transient. Maybe there is a special rule that deserialisation proxies’ transient fields are serialised anyway?

At the moment, I can’t tell if this is a bug in Gradle or not.

In the short term, using another List implementation will likely fix the issue.

jGleitz added a commit to jGleitz/spotless that referenced this issue Jan 8, 2025
jGleitz added a commit to jGleitz/spotless that referenced this issue Jan 8, 2025
@cloudshiftchris
Copy link
Author

Similar Gradle bug here: gradle/gradle#26942

That hints at it being a Gradle issue - serializing the collection using Gradle's serialization (instead of Java's), which bypasses the custom serialization protocol for these collections. On deserialize the Java code of course fails as the serialized data is not as expected.

@cloudshiftchris
Copy link
Author

Another Gradle issue: gradle/gradle#31523 that states that Gradle doesn't support serializing the value from List.of etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants