git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@986226 13f79535-47bb-0310-9956-ffa450edef68master
@@ -119,6 +119,10 @@ Fixed bugs: | |||||
<zipfileset>s that used the prefix or fullpath attributes. | <zipfileset>s that used the prefix or fullpath attributes. | ||||
Bugzilla Report 49605. | Bugzilla Report 49605. | ||||
* <tempfile createfile="true"> would cause an error unless the prefix | |||||
attribute has been specified. | |||||
Bugzilla Report 49755. | |||||
Other changes: | Other changes: | ||||
-------------- | -------------- | ||||
@@ -898,6 +898,8 @@ public class FileUtils { | |||||
return createTempFile(prefix, suffix, parentDir, false, false); | return createTempFile(prefix, suffix, parentDir, false, false); | ||||
} | } | ||||
private static final String NULL_PLACEHOLDER = "null"; | |||||
/** | /** | ||||
* Create a temporary file in a given directory. | * Create a temporary file in a given directory. | ||||
* | * | ||||
@@ -925,6 +927,12 @@ public class FileUtils { | |||||
String parent = (parentDir == null) | String parent = (parentDir == null) | ||||
? System.getProperty("java.io.tmpdir") | ? System.getProperty("java.io.tmpdir") | ||||
: parentDir.getPath(); | : parentDir.getPath(); | ||||
if (prefix == null) { | |||||
prefix = NULL_PLACEHOLDER; | |||||
} | |||||
if (suffix == null) { | |||||
suffix = NULL_PLACEHOLDER; | |||||
} | |||||
if (createFile) { | if (createFile) { | ||||
try { | try { | ||||
@@ -0,0 +1,26 @@ | |||||
<?xml version="1.0"?> | |||||
<!-- | |||||
Licensed to the Apache Software Foundation (ASF) under one or more | |||||
contributor license agreements. See the NOTICE file distributed with | |||||
this work for additional information regarding copyright ownership. | |||||
The ASF licenses this file to You under the Apache License, Version 2.0 | |||||
(the "License"); you may not use this file except in compliance with | |||||
the License. You may obtain a copy of the License at | |||||
http://www.apache.org/licenses/LICENSE-2.0 | |||||
Unless required by applicable law or agreed to in writing, software | |||||
distributed under the License is distributed on an "AS IS" BASIS, | |||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
See the License for the specific language governing permissions and | |||||
limitations under the License. | |||||
--> | |||||
<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit"> | |||||
<import file="../antunit-base.xml" /> | |||||
<target name="testCreateWithoutPrefix" | |||||
description="https://issues.apache.org/bugzilla/show_bug.cgi?id=49755"> | |||||
<tempfile property="tmp" createfile="true"/> | |||||
<au:assertFileExists file="${tmp}"/> | |||||
</target> | |||||
</project> |