Browse Source

Accommodate Windows bug encountered in both Sun and IBM JDKs.

Obtained from: Java Technology Forums at http://forums.java.sun.com


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276095 13f79535-47bb-0310-9956-ffa450edef68
master
Matthew Jason Benson 21 years ago
parent
commit
94565cfd88
1 changed files with 6 additions and 2 deletions
  1. +6
    -2
      src/main/org/apache/tools/ant/taskdefs/Delete.java

+ 6
- 2
src/main/org/apache/tools/ant/taskdefs/Delete.java View File

@@ -22,6 +22,7 @@ import java.util.Vector;
import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.condition.Os;
import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.PatternSet; import org.apache.tools.ant.types.PatternSet;
import org.apache.tools.ant.types.selectors.AndSelector; import org.apache.tools.ant.types.selectors.AndSelector;
@@ -535,12 +536,15 @@ public class Delete extends MatchingTask {
// protected and private methods // protected and private methods
//************************************************************************ //************************************************************************
/** /**
* Attempt to fix possible race condition when deleting
* files on WinXP. If the delete does not work,
* Accommodate Windows bug encountered in both Sun and IBM JDKs.
* Others possible. If the delete does not work, call System.gc(),
* wait a little and try again. * wait a little and try again.
*/ */
private boolean delete(File f) { private boolean delete(File f) {
if (!f.delete()) { if (!f.delete()) {
if (Os.isFamily("windows")) {
System.gc();
}
try { try {
Thread.sleep(DELETE_RETRY_SLEEP_MILLIS); Thread.sleep(DELETE_RETRY_SLEEP_MILLIS);
return f.delete(); return f.delete();


Loading…
Cancel
Save