spotbugs / spotbugs-gradle-plugin

https://plugins.gradle.org/plugin/com.github.spotbugs
Apache License 2.0
180 stars 68 forks source link

fix: remaining configuration cache issues #1245

Open lukasgraef opened 2 months ago

lukasgraef commented 2 months ago

resolves #1096

lukasgraef commented 2 months ago

In Gradle 7.6.3, testcases that perform two consecutive Builds using gradle's testkit, somehow fail if both builds are using config-cache. Deactivating the config-cache for one of these consecutive runs, resolves the problem. Therefore, I added the "--no-configuration-cache" flag to the first gradle testkit build in three testcases.

This issue is not present in the gradle 8.1 and "current" testcases.

hazendaz commented 2 months ago

using gradle's testkit, somehow fail if both builds are using con

I'm updating the build from gradle 7.6.3 to 7.6.4. Can you recheck that condition after you see master updated here?

lukasgraef commented 2 months ago

@hazendaz I tried it out locally with 7.6.4, but still no luck :( The weird thing is that the failure is caused by a ClassNotFoundException that happens only on the second consecutive run with config-cache on:

Caused by: java.lang.ClassNotFoundException: com.github.spotbugs.snom.SpotBugsTask$$Lambda$689/0x0000000801225728
    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)
mlopatkin commented 6 days ago

@hazendaz I tried it out locally with 7.6.4, but still no luck :( The weird thing is that the failure is caused by a ClassNotFoundException that happens only on the second consecutive run with config-cache on:

This means that the configuration cache cannot restore a lambda stored somewhere in the task state. You need to make the lambda (likely this one) serializable. As of 8.0, Gradle does that for you automatically, so you should only see this failure on 7.x.

You only see the failure on the second run because this issue only manifests upon loading from the cache. Starting with 8.0 or 8.1 Gradle loads the cached state even on the first run that saved the state, so there is no strict need to run the builds in tests twice.