Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3067
Root Cause
SpotlessPluginregistered adoLastaction on each subproject'scleantask that calledSpotlessCache.clearOnce(System.identityHashCode(project.getRootProject()))immediately during task execution.This caused two issues:
--parallel:mustRunAfter("clean")only orders tasks within the same subproject. When:b:cleanfinishes while:a:spotless<Format>is running concurrently in the same Gradle daemon,SpotlessCache.clear()closes activeFeatureClassLoaderinstances mid-format, resulting inClassNotFoundException/NoClassDefFoundError(e.g.,LINE_UNDEFINEDlint errors).System.identityHashCode(project.getRootProject())into the configuration cache causes subsequentcleanbuilds reusing the configuration cache to pass the samecacheKeytoSpotlessCache.clearOnce(cacheKey), skipping the clear entirely. In Gradle 9,project.getRootProject()can also return distinct wrapper instances per subproject.Changes
SpotlessTaskService: Added aclearCacheOnCloseflag set viaclearCacheOnClose()and checked inclose()(finallyblock afterratchet.close()), callingSpotlessCache.clearOnce(null)so the cache is cleared once at the end of the build after all tasks have completed without retaining a reference to the closedBuildService. WidenedusesServiceTolerateTestFailureto acceptTask.SpotlessPlugin: Replaced the immediateSpotlessCache.clearOnce(cacheKey)doLastlambda oncleanwith a staticClearSpotlessCacheOnCloseActionregistered alongsideusesServiceTolerateTestFailure(clean, taskService), preserving configuration-cache and isolated-projects compatibility.plugin-gradle/CHANGES.md: Added an entry under## [Unreleased]->### Fixed.CleanSpotlessCacheRaceTest: Added Gradle TestKit regression tests verifying::b:cleancompleting while:a:spotlessMiscis mid-execution does not close the in-useFeatureClassLoader.cleanstill clearsSpotlessCacheat build end on both configuration-cache misses and configuration-cache hits.clean+spotlessApply/spotlessCheckcontinue to work withorg.gradle.unsafe.isolated-projects=true.Verification
:plugin-gradle:spotlessCheck,:changelogCheck, and:plugin-gradle:testcoveringCleanSpotlessCacheRaceTest,IsolatedProjectTest,ConfigurationCacheTest,ConfigAvoidanceTest,MultiProjectTest,SpotlessTaskImplTest, andCompositeBuildRunToFixMessageTest(23 tests passed, 0 failures).