Browse Source

make junitlauncher and friends use FileUtils.createTempFile

master
Stefan Bodewig 5 years ago
parent
commit
d591851ae3
2 changed files with 10 additions and 12 deletions
  1. +3
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/AbstractJUnitResultFormatter.java
  2. +7
    -10
      src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/JUnitLauncherTask.java

+ 3
- 2
src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/AbstractJUnitResultFormatter.java View File

@@ -260,8 +260,9 @@ abstract class AbstractJUnitResultFormatter implements TestResultFormatter {
}

private FileOutputStream createFileStore() throws IOException {
this.filePath = Files.createTempFile(null, this.tmpFileSuffix);
this.filePath.toFile().deleteOnExit();
this.filePath = FileUtils.getFileUtils()
.createTempFile(null, this.tmpFileSuffix, null, true, true)
.toPath();
return new FileOutputStream(this.filePath.toFile());
}



+ 7
- 10
src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/JUnitLauncherTask.java View File

@@ -28,6 +28,7 @@ import org.apache.tools.ant.taskdefs.PumpStreamHandler;
import org.apache.tools.ant.types.CommandlineJava;
import org.apache.tools.ant.types.Environment;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.util.FileUtils;

import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamWriter;
@@ -224,8 +225,9 @@ public class JUnitLauncherTask extends Task {
}

private java.nio.file.Path dumpProjectProperties() throws IOException {
final java.nio.file.Path propsPath = Files.createTempFile(null, "properties");
propsPath.toFile().deleteOnExit();
final java.nio.file.Path propsPath = FileUtils.getFileUtils()
.createTempFile(null, "properties", null, true, true)
.toPath();
final Hashtable<String, Object> props = this.getProject().getProperties();
final Properties projProperties = new Properties();
projProperties.putAll(props);
@@ -364,14 +366,9 @@ public class JUnitLauncherTask extends Task {
}

private java.nio.file.Path newLaunchDefinitionXml() {
final java.nio.file.Path xmlFilePath;
try {
xmlFilePath = Files.createTempFile(null, ".xml");
} catch (IOException e) {
throw new BuildException("Failed to construct command line for test", e);
}
xmlFilePath.toFile().deleteOnExit();
return xmlFilePath;
return FileUtils.getFileUtils()
.createTempFile(null, ".xml", null, true, true)
.toPath();
}

private final class InVMLaunch implements LaunchDefinition {


Loading…
Cancel
Save