git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1554403 13f79535-47bb-0310-9956-ffa450edef68master
@@ -239,6 +239,7 @@ Matthew Hawthorne | |||||
Matthew Inger | Matthew Inger | ||||
Matthew Kuperus Heun | Matthew Kuperus Heun | ||||
Matthew Watson | Matthew Watson | ||||
Matthias Bhend | |||||
Michael Bayne | Michael Bayne | ||||
Michael Clarke | Michael Clarke | ||||
Michael Davey | Michael Davey | ||||
@@ -17,6 +17,10 @@ Fixed bugs: | |||||
different resource types. | different resource types. | ||||
Bugzilla Report 55097 | Bugzilla Report 55097 | ||||
* several calls to File#mkdirs could fall victim to a race condition | |||||
where another thread already created the same directory. | |||||
Bugzilla Report 55290 | |||||
Other changes: | Other changes: | ||||
-------------- | -------------- | ||||
@@ -924,14 +924,6 @@ | |||||
<first>Martin</first> | <first>Martin</first> | ||||
<last>von Gagern</last> | <last>von Gagern</last> | ||||
</name> | </name> | ||||
<name> | |||||
<first>Mathieu</first> | |||||
<last>Champlon</last> | |||||
</name> | |||||
<name> | |||||
<first>Mathieu</first> | |||||
<last>Peltier</last> | |||||
</name> | |||||
<name> | <name> | ||||
<first>Matt</first> | <first>Matt</first> | ||||
<last>Albrecht</last> | <last>Albrecht</last> | ||||
@@ -960,6 +952,22 @@ | |||||
<first>Matt</first> | <first>Matt</first> | ||||
<last>Small</last> | <last>Small</last> | ||||
</name> | </name> | ||||
<name> | |||||
<first>Matt</first> | |||||
<last>Wildig</last> | |||||
</name> | |||||
<name> | |||||
<first>Mathieu</first> | |||||
<last>Champlon</last> | |||||
</name> | |||||
<name> | |||||
<first>Mathieu</first> | |||||
<last>Peltier</last> | |||||
</name> | |||||
<name> | |||||
<first>Matthias</first> | |||||
<last>Bhend</last> | |||||
</name> | |||||
<name> | <name> | ||||
<first>Matthew</first> | <first>Matthew</first> | ||||
<last>Hawthorne</last> | <last>Hawthorne</last> | ||||
@@ -915,7 +915,7 @@ public class Copy extends Task { | |||||
for (int i = 0; i < dirs.length; i++) { | for (int i = 0; i < dirs.length; i++) { | ||||
File d = new File(dirs[i]); | File d = new File(dirs[i]); | ||||
if (!d.exists()) { | if (!d.exists()) { | ||||
if (!d.mkdirs()) { | |||||
if (!(d.mkdirs() || d.isDirectory())) { | |||||
log("Unable to create directory " | log("Unable to create directory " | ||||
+ d.getAbsolutePath(), Project.MSG_ERR); | + d.getAbsolutePath(), Project.MSG_ERR); | ||||
} else { | } else { | ||||
@@ -178,7 +178,7 @@ public class Move extends Copy { | |||||
} | } | ||||
File d = new File(toDirNames[i]); | File d = new File(toDirNames[i]); | ||||
if (!d.exists()) { | if (!d.exists()) { | ||||
if (!d.mkdirs()) { | |||||
if (!(d.mkdirs() || d.exists())) { | |||||
log("Unable to create directory " | log("Unable to create directory " | ||||
+ d.getAbsolutePath(), Project.MSG_ERR); | + d.getAbsolutePath(), Project.MSG_ERR); | ||||
} else { | } else { | ||||
@@ -281,7 +281,8 @@ public class Tar extends MatchingTask { | |||||
} | } | ||||
File parent = tarFile.getParentFile(); | File parent = tarFile.getParentFile(); | ||||
if (parent != null && !parent.isDirectory() && !parent.mkdirs()) { | |||||
if (parent != null && !parent.isDirectory() | |||||
&& !(parent.mkdirs() || parent.isDirectory())) { | |||||
throw new BuildException("Failed to create missing parent" | throw new BuildException("Failed to create missing parent" | ||||
+ " directory for " + tarFile); | + " directory for " + tarFile); | ||||
} | } | ||||
@@ -896,7 +896,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
private void ensureDirectoryFor(File targetFile) throws BuildException { | private void ensureDirectoryFor(File targetFile) throws BuildException { | ||||
File directory = targetFile.getParentFile(); | File directory = targetFile.getParentFile(); | ||||
if (!directory.exists()) { | if (!directory.exists()) { | ||||
if (!directory.mkdirs()) { | |||||
if (!(directory.mkdirs() || directory.isDirectory())) { | |||||
handleError("Unable to create directory: " | handleError("Unable to create directory: " | ||||
+ directory.getAbsolutePath()); | + directory.getAbsolutePath()); | ||||
} | } | ||||
@@ -645,7 +645,8 @@ public class Zip extends MatchingTask { | |||||
} | } | ||||
File parent = zipFile.getParentFile(); | File parent = zipFile.getParentFile(); | ||||
if (parent != null && !parent.isDirectory() && !parent.mkdirs()) { | |||||
if (parent != null && !parent.isDirectory() | |||||
&& !(parent.mkdirs() || parent.isDirectory())) { | |||||
throw new BuildException("Failed to create missing parent" | throw new BuildException("Failed to create missing parent" | ||||
+ " directory for " + zipFile); | + " directory for " + zipFile); | ||||
} | } | ||||
@@ -87,7 +87,8 @@ public class Gcj extends DefaultCompilerAdapter { | |||||
cmd.createArgument().setValue("-d"); | cmd.createArgument().setValue("-d"); | ||||
cmd.createArgument().setFile(destDir); | cmd.createArgument().setFile(destDir); | ||||
if (!destDir.exists() && !destDir.mkdirs()) { | |||||
if (!destDir.exists() | |||||
&& !(destDir.mkdirs() || destDir.isDirectory())) { | |||||
throw new BuildException("Can't make output directories. " | throw new BuildException("Can't make output directories. " | ||||
+ "Maybe permission is wrong. "); | + "Maybe permission is wrong. "); | ||||
} | } | ||||
@@ -279,7 +279,8 @@ public class Native2Ascii extends MatchingTask { | |||||
if (parentName != null) { | if (parentName != null) { | ||||
File parentFile = new File(parentName); | File parentFile = new File(parentName); | ||||
if ((!parentFile.exists()) && (!parentFile.mkdirs())) { | |||||
if (!parentFile.exists() | |||||
&& !(parentFile.mkdirs() || parentFile.isDirectory())) { | |||||
throw new BuildException("cannot create parent directory " | throw new BuildException("cannot create parent directory " | ||||
+ parentName); | + parentName); | ||||
} | } | ||||
@@ -305,7 +305,8 @@ public class Image extends MatchingTask { | |||||
} | } | ||||
File dstParent = newFile.getParentFile(); | File dstParent = newFile.getParentFile(); | ||||
if (!dstParent.isDirectory() && !dstParent.mkdirs()){ | |||||
if (!dstParent.isDirectory() | |||||
&& !(dstParent.mkdirs() || dstParent.isDirectory())) { | |||||
throw new BuildException("Failed to create parent directory " | throw new BuildException("Failed to create parent directory " | ||||
+ dstParent); | + dstParent); | ||||
} | } | ||||
@@ -319,7 +319,7 @@ public class Pvcs extends org.apache.tools.ant.Task { | |||||
if (!dir.exists()) { | if (!dir.exists()) { | ||||
log("Creating " + dir.getAbsolutePath(), | log("Creating " + dir.getAbsolutePath(), | ||||
Project.MSG_VERBOSE); | Project.MSG_VERBOSE); | ||||
if (dir.mkdirs()) { | |||||
if (dir.mkdirs() || dir.isDirectory()) { | |||||
log("Created " + dir.getAbsolutePath(), | log("Created " + dir.getAbsolutePath(), | ||||
Project.MSG_INFO); | Project.MSG_INFO); | ||||
} else { | } else { | ||||
@@ -362,7 +362,7 @@ public abstract class SOS extends Task implements SOSCmd { | |||||
// make sure localDir exists, create it if it doesn't | // make sure localDir exists, create it if it doesn't | ||||
File dir = getProject().resolveFile(localPath); | File dir = getProject().resolveFile(localPath); | ||||
if (!dir.exists()) { | if (!dir.exists()) { | ||||
boolean done = dir.mkdirs(); | |||||
boolean done = dir.mkdirs() || dir.isDirectory(); | |||||
if (!done) { | if (!done) { | ||||
String msg = "Directory " + localPath + " creation was not " | String msg = "Directory " + localPath + " creation was not " | ||||
+ "successful for an unknown reason"; | + "successful for an unknown reason"; | ||||
@@ -1308,7 +1308,8 @@ public class FileUtils { | |||||
throw new IOException("Failed to delete " + to + " while trying to rename " + from); | throw new IOException("Failed to delete " + to + " while trying to rename " + from); | ||||
} | } | ||||
File parent = to.getParentFile(); | File parent = to.getParentFile(); | ||||
if (parent != null && !parent.exists() && !parent.mkdirs()) { | |||||
if (parent != null && !parent.isDirectory() | |||||
&& !(parent.mkdirs() || parent.isDirectory())) { | |||||
throw new IOException("Failed to create directory " + parent | throw new IOException("Failed to create directory " + parent | ||||
+ " while trying to rename " + from); | + " while trying to rename " + from); | ||||
} | } | ||||
@@ -513,7 +513,7 @@ public class ResourceUtils { | |||||
File parent = destFile.getParentFile(); | File parent = destFile.getParentFile(); | ||||
if (parent != null && !parent.isDirectory() | if (parent != null && !parent.isDirectory() | ||||
&& !destFile.getParentFile().mkdirs()) { | |||||
&& !(parent.mkdirs() || parent.isDirectory())) { | |||||
throw new IOException("failed to create the parent directory" | throw new IOException("failed to create the parent directory" | ||||
+ " for " + destFile); | + " for " + destFile); | ||||
} | } | ||||