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 bug when gradle clean spotlessCheck was called on parallel build #501

Merged
merged 3 commits into from
Jan 1, 2020

Conversation

nedtwigg
Copy link
Member

@nedtwigg nedtwigg commented Dec 31, 2019

Fixes #243

@nedtwigg nedtwigg merged commit 402be65 into master Jan 1, 2020
@nedtwigg nedtwigg deleted the feat/fix-parallel branch January 1, 2020 00:29
// actually happen (as desired)
//
// we use System.identityHashCode() to avoid a memory leak by hanging on to the reference directly
SpotlessCache.clearOnce(System.identityHashCode(project.getRootProject()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nedtwigg Reading the source code for SpotlessCache::clearOnce, I'm unclear on why passing project.getRootProject() to the method would cause the method to hang onto it; AFAICT the method never stores the reference inside a field or something similar. 🤔

So I was wondering if you could help me understand why the call to System::identityHashCode is needed here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be a better way to spell it, but I think the javadoc is the clearest explanation.

if (key == null || !key.equals(lastClear)) {
	lastClear = key;
} else {
	// only clear once
	return false;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, that lastClear = key line is what I'd missed! Thank you @nedtwigg. :)

@nedtwigg
Copy link
Member Author

nedtwigg commented Jan 2, 2020

Published in 3.27.0 (twitter announcement)

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.

Exceptions when running clean & spotlessCheck during same build with buildcache
2 participants