Regression in 8.6.0: groovyGradle/greclipse fails with "roundtripStateInternal or equalityStateInternal should be non-null" during input fingerprinting
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- groovy, java
- 领域
- build-system
调研方向
首先,使用 ./gradlew spotlessCheck --no-daemon --no-build-cache --stacktrace 在干净的 Gradle user home 中复现该故障。沿着显示的 stack trace 阅读 FormatterStepSerializationRoundtrip.java、ConfigurationCacheHackList.java 以及相关的序列化类。当新 provision 的 greclipse task 不再在输入指纹计算期间失败时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Summary
Starting with Spotless 8.6.0, the groovyGradle { greclipse() } task fails with:
If the initializer was null, then one of roundtripStateInternal or equalityStateInternal should be non-null, and neither was
This is a regression: 8.4.0 and 8.5.0 work with the exact same project/config/Gradle version; 8.6.0 fails. Pinning back to 8.5.0 is our current workaround.
It is closely related to (and may be the same root cause as) #2927 and #2502, but we can pinpoint it to the 8.5.0 → 8.6.0 bump, and it does not require the configuration cache (it happens with config cache disabled / not configured).
Environment
- Spotless Gradle plugin 8.6.0 (8.4.0 and 8.5.0 OK)
- Gradle 9.5.1
- JDK 26 (Temurin) — also reproduces on the same setup regardless
- Formatter:
groovyGradle { greclipse() }(default greclipse → Groovy-Eclipse5.7.0/e4.35, Groovy5.0.0) - Configuration cache: not enabled
- Build cache: disabled on the command line (
--no-build-cache) — does not affect the outcome
Spotless config (relevant part)
spotless {
groovyGradle {
toggleOffOn()
greclipse()
leadingTabsToSpaces()
}
}
How to reproduce
Run on a clean Gradle user home (e.g. a fresh CI container where greclipse is provisioned from scratch):
./gradlew spotlessCheck --no-daemon --no-build-cache --stacktrace
:spotlessGroovyGradle fails. It does not reproduce against a warm local cache where greclipse is already provisioned — which suggests the failure is tied to the freshly-built greclipse step state rather than to any formatting violation.
Stack trace
The exception is thrown while Gradle fingerprints the task's input properties (before execution), when it calls hashCode() on Spotless's ConfigurationCacheHackList:
Caused by: java.lang.IllegalStateException: If the initializer was null, then one of roundtripStateInternal or equalityStateInternal should be non-null, and neither was
at com.diffplug.spotless.FormatterStepSerializationRoundtrip.writeObject(FormatterStepSerializationRoundtrip.java:74)
at com.diffplug.spotless.FormatterStepSerializationRoundtrip$HackClone.writeObject(FormatterStepSerializationRoundtrip.java:121)
at com.diffplug.spotless.ConfigurationCacheHackList.writeObject(ConfigurationCacheHackList.java:78)
at com.diffplug.spotless.LazyForwardingEquality.toBytes(LazyForwardingEquality.java:110)
at com.diffplug.spotless.FormatterStepEqualityOnStateSerialization.lambda$serializedState$0(FormatterStepEqualityOnStateSerialization.java:95)
at com.diffplug.spotless.ThrowingEx.get(ThrowingEx.java:67)
at com.diffplug.spotless.FormatterStepEqualityOnStateSerialization.serializedState(FormatterStepEqualityOnStateSerialization.java:95)
at com.diffplug.spotless.FormatterStepEqualityOnStateSerialization.hashCode(FormatterStepEqualityOnStateSerialization.java:75)
at com.diffplug.spotless.FormatterStepSerializationRoundtrip$HackClone.hashCode(FormatterStepSerializationRoundtrip.java:142)
at com.diffplug.spotless.ConfigurationCacheHackList.hashCode(ConfigurationCacheHackList.java:151)
at org.gradle.internal.execution.impl.DefaultInputFingerprinter$InputCollectingVisitor.visitInputProperty(DefaultInputFingerprinter.java:131)
at org.gradle.api.internal.tasks.execution.TaskExecution.visitMutableInputs(TaskExecution.java:336)
at org.gradle.internal.execution.impl.DefaultInputFingerprinter.fingerprintInputProperties(DefaultInputFingerprinter.java:77)
at org.gradle.internal.execution.steps.CaptureMutableStateBeforeExecutionStep.captureExecutionStateWithOutputs(CaptureMutableStateBeforeExecutionStep.java:124)
...
at org.gradle.internal.execution.steps.LoadPreviousExecutionStateStep.executeMutable(LoadPreviousExecutionStateStep.java:36)
Analysis / likely cause
- The failure is in
FormatterStepSerializationRoundtrip.writeObject(line 74), which asserts that ifinitializer == nullthen one ofroundtripStateInternal/equalityStateInternalmust be non-null — and here both are null. - It is reached via
ConfigurationCacheHackList.hashCode()during Gradle's input fingerprinting (DefaultInputFingerprinter/CaptureMutableStateBeforeExecutionStep), i.e. before the task action runs — so it triggers for ordinary up-to-date checking, independent of the build cache and without the configuration cache. - Because it only reproduces with a freshly provisioned greclipse (clean Gradle user home) and not against a warm cache, the greclipse step's state appears to be left without a computed
roundtripStateInternal/equalityStateInternal(initializer already consumed) at the point Gradle serializes it for the fingerprint.
Workaround
Pin the Spotless Gradle plugin to 8.5.0.
Happy to provide a minimal reproducer repo or extra logs (--info/--debug) if helpful.
- 主要语言
- Java
- 星标
- 5.7k
- 派生
- 560
- 平均合并
- 1 天 13 小时
- 30 天内合并 PR
- 43
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
diffplug/spotless 的其他 Issue
-
难度 5/5 一周以上 新手友好度 15/100
-
难度 5/5 一周以上 新手友好度 35/100
-
难度 3/5 1-2 天 新手友好度 66/100
-
难度 3/5 1-2 天 新手友好度 68/100
-
难度 4/5 3-5 天 新手友好度 52/100
查看 diffplug/spotless 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
infinispan/infinispan#18150 ·
-
难度 2/5 1-3 小时 新手友好度 84/100
-
untriaged
难度 2/5 1-3 小时 新手友好度 82/100
opensearch-project/k-NN#3597 ·
-
bug
难度 2/5 1-3 小时 新手友好度 88/100
-
bug
难度 2/5 1-3 小时 新手友好度 82/100