You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2020/05/03 15:24:20 UTC

[ant] branch master updated: make junitlauncher and friends use FileUtils.createTempFile

This is an automated email from the ASF dual-hosted git repository.

bodewig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ant.git


The following commit(s) were added to refs/heads/master by this push:
     new d591851  make junitlauncher and friends use FileUtils.createTempFile
d591851 is described below

commit d591851ae3921172bb825b5a5344afa3de0e28ca
Author: Stefan Bodewig <bo...@apache.org>
AuthorDate: Sun May 3 17:24:03 2020 +0200

    make junitlauncher and friends use FileUtils.createTempFile
---
 .../junitlauncher/AbstractJUnitResultFormatter.java     |  5 +++--
 .../junitlauncher/confined/JUnitLauncherTask.java       | 17 +++++++----------
 2 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/AbstractJUnitResultFormatter.java b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/AbstractJUnitResultFormatter.java
index 833ae0f..dc9847d 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/AbstractJUnitResultFormatter.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/AbstractJUnitResultFormatter.java
@@ -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());
         }
 
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/JUnitLauncherTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/JUnitLauncherTask.java
index 3e0e671..0d16ed0 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/JUnitLauncherTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/JUnitLauncherTask.java
@@ -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 {