-
Notifications
You must be signed in to change notification settings - Fork 506
git pre push hook, task compatible with gradle configuration cache + parallel execution handling #2570
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
Conversation
| return; | ||
| } | ||
|
|
||
| synchronized (LOCK) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used the simplest strategy: double-checked locking with synchronized. Since this task is meant to be run manually by the user, it’s totally OK. It’s a simple and robust solution that doesn’t affect performance, so in my opinion this is a good approach.
If you disagree or have a better idea, I’m happy to hear it!
One more corner case related to parallel execution: the current solution prevents parallel file modification within a single JVM process.
However, if a user runs Gradle in multiple consoles at the same time, we could end up with parallel creation/editing of the same file with a few Gradle processes...
That could be handled using a file lock on the OS level with Java's FileChannel, but I’m not sure we need to worry about this case — it’s very unlikely to happen in practice.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not worth the complexity, managing within a single process is good enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nedtwigg
If there are no other concerns or comments, can we go ahead and merge this?
26423f1 to
74d1d85
Compare
42a7d4e to
592c088
Compare
592c088 to
58c2683
Compare
|
Published in |
Configuration Cache Support & Thread Safety for Git Pre-push Hook
This PR introduces two important improvements for the
spotlessInstallGitPrePushHooktask:What’s Changed
org.gradle.configuration-cache=trueWhy