mbenson 2004/04/22 14:33:06
Modified: . Tag: ANT_16_BRANCH WHATSNEW
src/main/org/apache/tools/ant/taskdefs Tag: ANT_16_BRANCH
Redirector.java
src/main/org/apache/tools/ant/util Tag: ANT_16_BRANCH
LazyFileOutputStream.java
Log:
Merge Redirector bugfix to 1.6 branch.
Revision Changes Path
No revision
No revision
1.503.2.79 +5 -0 ant/WHATSNEW
Index: WHATSNEW
===================================================================
RCS file: /home/cvs/ant/WHATSNEW,v
retrieving revision 1.503.2.78
retrieving revision 1.503.2.79
diff -u -r1.503.2.78 -r1.503.2.79
--- WHATSNEW 21 Apr 2004 07:19:13 -0000 1.503.2.78
+++ WHATSNEW 22 Apr 2004 21:33:06 -0000 1.503.2.79
@@ -61,6 +61,11 @@
* Ant failed to locate tools.jar if the jre directory name wasn't all
lowercase. Bugzilla Report 25798.
+ * Redirector exhibited inconsistent behavior with regard to split
+ output. When sent to file only, files would be created in all
+ cases; when split file-property, files were only created if
+ writes were performed.
+
Other changes:
--------------
No revision
No revision
1.11.2.5 +2 -8 ant/src/main/org/apache/tools/ant/taskdefs/Redirector.java
Index: Redirector.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Redirector.java,v
retrieving revision 1.11.2.4
retrieving revision 1.11.2.5
diff -u -r1.11.2.4 -r1.11.2.5
--- Redirector.java 9 Mar 2004 17:01:34 -0000 1.11.2.4
+++ Redirector.java 22 Apr 2004 21:33:06 -0000 1.11.2.5
@@ -231,7 +231,7 @@
errorStream = new LogOutputStream(managingTask, Project.MSG_WARN);
} else {
if (out != null) {
- outputStream = new LazyFileOutputStream(out, append);
+ outputStream = new LazyFileOutputStream(out, append, true);
managingTask.log("Output redirected to " + out,
Project.MSG_VERBOSE);
}
@@ -257,7 +257,7 @@
}
if (error != null) {
- errorStream = new LazyFileOutputStream(error, append);
+ errorStream = new LazyFileOutputStream(error, append, true);
managingTask.log("Error redirected to " + error,
Project.MSG_VERBOSE);
}
@@ -421,15 +421,9 @@
inputStream.close();
}
- if (outputStream instanceof LazyFileOutputStream) {
- ((LazyFileOutputStream) outputStream).open();
- }
outputStream.close();
if (errorStream != outputStream) {
- if (errorStream instanceof LazyFileOutputStream) {
- ((LazyFileOutputStream) errorStream).open();
- }
errorStream.close();
}
No revision
No revision
1.1.2.4 +15 -0 ant/src/main/org/apache/tools/ant/util/LazyFileOutputStream.java
Index: LazyFileOutputStream.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/util/LazyFileOutputStream.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- LazyFileOutputStream.java 9 Feb 2004 22:12:43 -0000 1.1.2.3
+++ LazyFileOutputStream.java 22 Apr 2004 21:33:06 -0000 1.1.2.4
@@ -33,6 +33,7 @@
private FileOutputStream fos;
private File file;
private boolean append;
+ private boolean alwaysCreate;
private boolean opened = false;
private boolean closed = false;
@@ -67,8 +68,19 @@
* it.
*/
public LazyFileOutputStream(File file, boolean append) {
+ this(file, append, false);
+ }
+
+ /**
+ * Creates a stream that will eventually write to the file with
+ * the given name, optionally append to instead of replacing
+ * it, and optionally always create a file (even if zero length).
+ */
+ public LazyFileOutputStream(File file, boolean append,
+ boolean alwaysCreate) {
this.file = file;
this.append = append;
+ this.alwaysCreate = alwaysCreate;
}
/**
@@ -81,6 +93,9 @@
}
public synchronized void close() throws IOException {
+ if (alwaysCreate && !closed) {
+ ensureOpened();
+ }
if (opened) {
fos.close();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
|