diff --git a/WHATSNEW b/WHATSNEW index c6c27fc6c..e4e82b445 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -119,6 +119,10 @@ Fixed bugs: s that used the prefix or fullpath attributes. Bugzilla Report 49605. + * would cause an error unless the prefix + attribute has been specified. + Bugzilla Report 49755. + Other changes: -------------- diff --git a/src/main/org/apache/tools/ant/util/FileUtils.java b/src/main/org/apache/tools/ant/util/FileUtils.java index fe1b6859a..38b82f9dc 100644 --- a/src/main/org/apache/tools/ant/util/FileUtils.java +++ b/src/main/org/apache/tools/ant/util/FileUtils.java @@ -898,6 +898,8 @@ public class FileUtils { return createTempFile(prefix, suffix, parentDir, false, false); } + private static final String NULL_PLACEHOLDER = "null"; + /** * Create a temporary file in a given directory. * @@ -925,6 +927,12 @@ public class FileUtils { String parent = (parentDir == null) ? System.getProperty("java.io.tmpdir") : parentDir.getPath(); + if (prefix == null) { + prefix = NULL_PLACEHOLDER; + } + if (suffix == null) { + suffix = NULL_PLACEHOLDER; + } if (createFile) { try { diff --git a/src/tests/antunit/taskdefs/tempfile-test.xml b/src/tests/antunit/taskdefs/tempfile-test.xml new file mode 100644 index 000000000..2749216dc --- /dev/null +++ b/src/tests/antunit/taskdefs/tempfile-test.xml @@ -0,0 +1,26 @@ + + + + + + + + + +