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

Fix hard-to-reproduce race condition in SpotlessCheck. #671

Merged
merged 4 commits into from
Aug 25, 2020

Conversation

nedtwigg
Copy link
Member

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 the build/spotless/<formatName> directory. It only fails 1 out of 3 or 4 invocations.

// now it is "git dirty" but "format clean"
assertPass("spotlessCheck");

There is an easy fix, which is for spotlessCheck to double-check that files in build/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

  • require a low-timestamp-resolution-filesystem
  • caching with both JGit and Gradle
  • coupled with doing multiple independent gradle invocations all without crossing 1 second timestamp boundary

In short, an easy workaround is probably the right answer :)

@nedtwigg nedtwigg merged commit 6f1177f into main Aug 25, 2020
@nedtwigg nedtwigg deleted the feat/race-condition branch August 25, 2020 05:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant