Ralph:
What you have identified is in fact a bug. Thanks for
reporting it. The attached patch resolves this issue.
Thanks,
Magesh
On Tue, 23 Oct 2001 Ralph Bohnet wrote :
> I am not sure if this is a bug or expected behavior. A
> property file
> exists, and I use the task
> propertyfile to edit it. Later, if I want to delete it,
> I receive a failure
> on the delete task.
> If the property file doesn't exist, then it creates and
> deletes it
> successfully.
> Is this the expected behavior?
>
> I have a sample build.xml to confirm what I am seeing.
> If I remove the touch task and ensure there is no
> property file, all is
> well.
> But if 'foobar.properties' exists, it successfully
> edits it, but fails to
> delete it.
>
> I am using Ant 1.4.1, JDK 1.3 on WinNT.
>
> Thanks
>
> Ralph Bohnet
> EFA Software Inc
>
> ----------------- build.xml --- Cut here
> -----------------------------
> <?xml version="1.0"?>
> <project name="Test PropertyFile" default="test"
> basedir=".">
>
> <target name="test" >
>
> <!-- Create the file -->
> <touch file="foobar.properties"/>
>
> <propertyfile file="foobar.properties">
> <entry key="db.url" value="jdbc:odbc:polite"/>
> </propertyfile>
> <delete file="foobar.properties"/>
> </target>
>
> </project>
Index: PropertyFile.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java,v
retrieving revision 1.6
diff -u -w -r1.6 PropertyFile.java
--- PropertyFile.java 2001/10/18 10:16:17 1.6
+++ PropertyFile.java 2001/10/22 20:44:33
@@ -203,9 +203,13 @@
if (m_propertyfile.exists())
{
log("Updating property file:
"+m_propertyfile.getAbsolutePath());
- m_properties.load(new BufferedInputStream(
- new FileInputStream(m_propertyfile)));
+ FileInputStream fis = new FileInputStream(m_propertyfile);
+ BufferedInputStream bis = new BufferedInputStream(fis);
+ m_properties.load(bis);
+ if (fis != null) {
+ fis.close();
}
+ }
else
{
log("Creating new property file: "+