[GRADLE-2699] Gradle wrapper race condition when concurrently executing Created: 07/Mar/13 Updated: 25/Mar/13 Resolved: 25/Mar/13
We've been getting errors such as this from the Gradle Wrapper quite frequently when running Gradle builds on cloudbees CI:
I decided to look at the code in the Gradle Wrapper to see what it was doing around this time, and I noticed a possible race condition that could be causing the problem:
If two or more builds are running as the same user on the same machine at the same time (which is normal in a CI environment), then it appears two or more builds could end up trying to unzip the distribution at the same time and deleting the tmp file from under the feet of the other one.
I haven't tried to debug this - this is just a guess looking at some suspicious code.
|Comment by Gradle Forums [ 07/Mar/13 ]|
One way of fixing this would be to generate the temp download file name using a random UUID to (virtually) eliminate the possibility of clashes, then use an atomic rename to rename the file (if it doesn't already exist) when the download is complete:
http://docs.oracle.com/javase/7/docs/..., java.nio.file.Path, java.nio.file.CopyOption...)