Browse Source

More robust cleanup of temporary files, PR 17512

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275490 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 21 years ago
parent
commit
6b62a56cce
14 changed files with 18 additions and 1 deletions
  1. +1
    -0
      src/main/org/apache/tools/ant/taskdefs/FixCRLF.java
  2. +1
    -0
      src/main/org/apache/tools/ant/taskdefs/Javadoc.java
  3. +1
    -0
      src/main/org/apache/tools/ant/taskdefs/Replace.java
  4. +1
    -0
      src/main/org/apache/tools/ant/taskdefs/Zip.java
  5. +1
    -0
      src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
  6. +1
    -0
      src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java
  7. +2
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/Cab.java
  8. +1
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java
  9. +1
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
  10. +4
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java
  11. +1
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
  12. +1
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovMerge.java
  13. +1
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Coverage.java
  14. +1
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java

+ 1
- 0
src/main/org/apache/tools/ant/taskdefs/FixCRLF.java View File

@@ -404,6 +404,7 @@ public class FixCRLF extends MatchingTask {
// Set up the output Writer
try {
tmpFile = fileUtils.createTempFile("fixcrlf", "", null);
tmpFile.deleteOnExit();
Writer writer = (encoding == null) ? new FileWriter(tmpFile)
: new OutputStreamWriter(new FileOutputStream(tmpFile),
encoding);


+ 1
- 0
src/main/org/apache/tools/ant/taskdefs/Javadoc.java View File

@@ -1919,6 +1919,7 @@ public class Javadoc extends Task {
if (useExternalFile) {
if (tmpList == null) {
tmpList = fileUtils.createTempFile("javadoc", "", null);
tmpList.deleteOnExit();
toExecute.createArgument()
.setValue("@" + tmpList.getAbsolutePath());
}


+ 1
- 0
src/main/org/apache/tools/ant/taskdefs/Replace.java View File

@@ -399,6 +399,7 @@ public class Replace extends MatchingTask {

File temp = fileUtils.createTempFile("rep", ".tmp",
fileUtils.getParentFile(src));
temp.deleteOnExit();

Reader reader = null;
Writer writer = null;


+ 1
- 0
src/main/org/apache/tools/ant/taskdefs/Zip.java View File

@@ -416,6 +416,7 @@ public class Zip extends MatchingTask {
renamedFile =
fileUtils.createTempFile("zip", ".tmp",
fileUtils.getParentFile(zipFile));
renamedFile.deleteOnExit();

try {
fileUtils.rename(zipFile, renamedFile);


+ 1
- 0
src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java View File

@@ -445,6 +445,7 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter {
userDir = new File(userDirName);
}
tmpFile = fileUtils.createTempFile("files", "", userDir);
tmpFile.deleteOnExit();
out = new PrintWriter(new FileWriter(tmpFile));
for (int i = firstFileName; i < args.length; i++) {
if (quoteFiles && args[i].indexOf(" ") > -1) {


+ 1
- 0
src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java View File

@@ -245,6 +245,7 @@ public class CvsTagDiff extends AbstractCvsTask {
File tmpFile = null;
try {
tmpFile = myfileUtils.createTempFile("cvstagdiff", ".log", null);
tmpFile.deleteOnExit();
setOutput(tmpFile);

// run the cvs command


+ 2
- 0
src/main/org/apache/tools/ant/taskdefs/optional/Cab.java View File

@@ -192,6 +192,7 @@ public class Cab extends MatchingTask {
protected File createListFile(Vector files)
throws IOException {
File listFile = fileUtils.createTempFile("ant", "", null);
listFile.deleteOnExit();

PrintWriter writer = new PrintWriter(new FileOutputStream(listFile));

@@ -322,6 +323,7 @@ public class Cab extends MatchingTask {

if (!doVerbose) {
outFile = fileUtils.createTempFile("ant", "", null);
outFile.deleteOnExit();
exec.setOutput(outFile);
}



+ 1
- 0
src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java View File

@@ -322,6 +322,7 @@ public class ReplaceRegExp extends Task {
protected void doReplace(File f, int options)
throws IOException {
File temp = fileUtils.createTempFile("replace", ".txt", null);
temp.deleteOnExit();

Reader r = null;
Writer w = null;


+ 1
- 0
src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java View File

@@ -769,6 +769,7 @@ public class JUnitTask extends Task {
File propsFile =
FileUtils.newFileUtils().createTempFile("junit", ".properties",
tmpDir != null ? tmpDir : getProject().getBaseDir());
propsFile.deleteOnExit();
cmd.createArgument().setValue("propsfile="
+ propsFile.getAbsolutePath());
Hashtable p = getProject().getProperties();


+ 4
- 1
src/main/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java View File

@@ -320,7 +320,10 @@ public abstract class AbstractMetamataTask extends Task {
}

protected final File createTmpFile() {
return FileUtils.newFileUtils().createTempFile("metamata", ".tmp", getProject().getBaseDir());
File tmpFile = FileUtils.newFileUtils()
.createTempFile("metamata", ".tmp", getProject().getBaseDir());
tmpFile.deleteOnExit();
return tmpFile;
}

/**


+ 1
- 0
src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java View File

@@ -1576,6 +1576,7 @@ public class FTP
throw new BuildException(ioe, getLocation());
}
if (!found) {
localFile.deleteOnExit();
return localFile;
}
}


+ 1
- 0
src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovMerge.java View File

@@ -196,6 +196,7 @@ public class CovMerge extends CovBase {
protected File createParamFile() throws BuildException {
File[] snapshots = getSnapshots();
File file = createTempFile("jpcovm");
file.deleteOnExit();
FileWriter fw = null;
try {
fw = new FileWriter(file);


+ 1
- 0
src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Coverage.java View File

@@ -449,6 +449,7 @@ public class Coverage extends CovBase {
protected File createParamFile() throws BuildException {
//@todo change this when switching to JDK 1.2 and use File.createTmpFile()
File file = createTempFile("jpcov");
file.deleteOnExit();
log("Creating parameter file: " + file, Project.MSG_VERBOSE);

// options need to be one per line in the parameter file


+ 1
- 0
src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java View File

@@ -417,6 +417,7 @@ public class Symlink extends Task {
File parentDir = new File(parentStr);
FileUtils fu = FileUtils.newFileUtils();
File temp = fu.createTempFile("symlink", ".tmp", parentDir);
temp.deleteOnExit();
try {
try {
fu.rename(canfil, temp);


Loading…
Cancel
Save