From fdb4a2a2f779019d94cacaf6408cb96fea4c90c4 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Tue, 7 Jun 2016 21:23:59 +0300 Subject: [PATCH] IDEA-157216 External build may fail with 'Unable to create temporary file' --- .../util-rt/src/com/intellij/openapi/util/io/FileUtilRt.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/util-rt/src/com/intellij/openapi/util/io/FileUtilRt.java b/platform/util-rt/src/com/intellij/openapi/util/io/FileUtilRt.java index f41e90e23daa..e4576d7279d2 100644 --- a/platform/util-rt/src/com/intellij/openapi/util/io/FileUtilRt.java +++ b/platform/util-rt/src/com/intellij/openapi/util/io/FileUtilRt.java @@ -371,6 +371,7 @@ public class FileUtilRt { return file; } + private static final Random RANDOM = new Random(); @NotNull private static File doCreateTempFile(@NotNull File dir, @NotNull @NonNls String prefix, @@ -412,7 +413,7 @@ public class FileUtilRt { } i++; // for some reason the file1 can't be created (previous file1 was deleted but got locked by anti-virus?). try file2. if (i > 2) { - i = 2 + (int)(System.nanoTime() % maxFileNumber); // generate random suffix if too many failures + i = 2 + RANDOM.nextInt(maxFileNumber); // generate random suffix if too many failures } } }