From e987d2709b210511b7dd07b59fc4bb93b7469721 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Sat, 3 May 2008 00:31:13 +0000 Subject: [PATCH] It's not obvious to me if the race condition could ever occur, but Rama and I experienced a very suspicious failure once, and we are hoping that this would fix it. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@9018 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/FilePath.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/hudson/FilePath.java b/core/src/main/java/hudson/FilePath.java index fc99724b78..12382c6661 100644 --- a/core/src/main/java/hudson/FilePath.java +++ b/core/src/main/java/hudson/FilePath.java @@ -357,9 +357,19 @@ public final class FilePath implements Serializable { * Creates this directory. */ public void mkdirs() throws IOException, InterruptedException { - if(act(new FileCallable() { + if(!act(new FileCallable() { public Boolean invoke(File f, VirtualChannel channel) throws IOException { - return !f.mkdirs() && !f.exists(); + if(f.mkdirs() || f.exists()) + return true; // OK + + // following Ant task to avoid possible race condition. + try { + Thread.sleep(10); + } catch (InterruptedException e) { + // ignore + } + + return f.mkdirs() || f.exists(); } })) throw new IOException("Failed to mkdirs: "+remote); -- GitLab