git pre push hook, task compatible with gradle configuration cache + parallel execution handling#2570
Conversation
| return; | ||
| } | ||
|
|
||
| synchronized (LOCK) { |
There was a problem hiding this comment.
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.
not worth the complexity, managing within a single process is good enough
There was a problem hiding this comment.
@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