Fix hard-to-reproduce race condition in SpotlessCheck. #671
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.
I've never seen this bug on Win or Linux, but it started happening on my mac dev box today.
GitRatchetGradleTest
can occasionally fail, in the following way. This line was failing, claiming that a file was dirty. But the file was actually formatted correctly, and just leftover in thebuild/spotless/<formatName>
directory. It only fails 1 out of 3 or 4 invocations.spotless/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/GitRatchetGradleTest.java
Lines 203 to 204 in de2d84e
There is an easy fix, which is for
spotlessCheck
to double-check that files inbuild/spotless/<formatName>
really are different than what is on disk. It needs to do this anyway in order to generate the format violations, so it might as well be eager about it.Given how difficult it is to trigger, triggering the bug is likely to
gradle
invocations all without crossing 1 second timestamp boundaryIn short, an easy workaround is probably the right answer :)