diff --git a/src/main/org/apache/tools/ant/DemuxOutputStream.java b/src/main/org/apache/tools/ant/DemuxOutputStream.java index 8694ae4be..1d2bdae4c 100644 --- a/src/main/org/apache/tools/ant/DemuxOutputStream.java +++ b/src/main/org/apache/tools/ant/DemuxOutputStream.java @@ -191,7 +191,9 @@ public class DemuxOutputStream extends OutputStream { * @see Project#demuxOutput(String,boolean) */ protected void processBuffer(ByteArrayOutputStream buffer) { - processBuffer(buffer, true); + String output = buffer.toString(); + project.demuxOutput(output, isErrorStream); + resetBufferInfo(); } /** @@ -202,10 +204,9 @@ public class DemuxOutputStream extends OutputStream { * * @see Project#demuxOutput(String,boolean) */ - protected void processBuffer(ByteArrayOutputStream buffer, - boolean terminated) { + protected void processFlush(ByteArrayOutputStream buffer) { String output = buffer.toString(); - project.demuxOutput(output, isErrorStream, terminated); + project.demuxFlush(output, isErrorStream); resetBufferInfo(); } @@ -230,7 +231,7 @@ public class DemuxOutputStream extends OutputStream { public void flush() throws IOException { BufferInfo bufferInfo = getBufferInfo(); if (bufferInfo.buffer.size() > 0) { - processBuffer(bufferInfo.buffer, false); + processFlush(bufferInfo.buffer); } } } diff --git a/src/main/org/apache/tools/ant/Project.java b/src/main/org/apache/tools/ant/Project.java index 5e9cb6497..0a9d42298 100644 --- a/src/main/org/apache/tools/ant/Project.java +++ b/src/main/org/apache/tools/ant/Project.java @@ -1228,29 +1228,40 @@ public class Project { * or information (false). */ public void demuxOutput(String line, boolean isError) { - demuxOutput(line, isError, true); + Task task = (Task) threadTasks.get(Thread.currentThread()); + if (task == null) { + fireMessageLogged(this, line, isError ? MSG_ERR : MSG_INFO); + } else { + if (isError) { + task.handleErrorOutput(line); + } else { + task.handleOutput(line); + } + } } /** - * Demultiplexes output so that each task receives the appropriate + * Demultiplexes flush operation so that each task receives the appropriate * messages. If the current thread is not currently executing a task, * the message is logged directly. * + * @since Ant 1.5.2 + * * @param line Message to handle. Should not be null. * @param isError Whether the text represents an error (true) * or information (false). * @param terminated true if this line should be terminated with an * end-of-line marker */ - public void demuxOutput(String line, boolean isError, boolean terminated) { + public void demuxFlush(String line, boolean isError) { Task task = (Task) threadTasks.get(Thread.currentThread()); if (task == null) { fireMessageLogged(this, line, isError ? MSG_ERR : MSG_INFO); } else { if (isError) { - task.handleErrorOutput(line, terminated); + task.handleErrorFlush(line); } else { - task.handleOutput(line, terminated); + task.handleFlush(line); } } } diff --git a/src/main/org/apache/tools/ant/Task.java b/src/main/org/apache/tools/ant/Task.java index 1f7a788d9..ac2e9f4f9 100644 --- a/src/main/org/apache/tools/ant/Task.java +++ b/src/main/org/apache/tools/ant/Task.java @@ -298,18 +298,18 @@ public abstract class Task extends ProjectComponent { * @param line The line of output to log. Should not be null. */ protected void handleOutput(String line) { - handleOutput(line + "X7", true); + log(line, Project.MSG_INFO); } /** * Handles a line of output by logging it with the INFO priority. * * @param line The line of output to log. Should not be null. - * @param terminated true if this line should be terminated with an - * end-of-line marker + * + * @since Ant 1.5.2 */ - protected void handleOutput(String line, boolean terminated) { - log(line, Project.MSG_INFO); + protected void handleFlush(String line) { + handleOutput(line); } /** @@ -318,18 +318,18 @@ public abstract class Task extends ProjectComponent { * @param line The error line to log. Should not be null. */ protected void handleErrorOutput(String line) { - handleErrorOutput(line, true); + log(line, Project.MSG_ERR); } /** * Handles an error line by logging it with the INFO priority. * * @param line The error line to log. Should not be null. - * @param terminated true if this line should be terminated with an - * end-of-line marker + * + * @since Ant 1.5.2 */ - protected void handleErrorOutput(String line, boolean terminated) { - log(line, Project.MSG_ERR); + protected void handleErrorFlush(String line) { + handleErrorOutput(line); } /** diff --git a/src/main/org/apache/tools/ant/UnknownElement.java b/src/main/org/apache/tools/ant/UnknownElement.java index e97f7c6aa..f2bab4800 100644 --- a/src/main/org/apache/tools/ant/UnknownElement.java +++ b/src/main/org/apache/tools/ant/UnknownElement.java @@ -161,11 +161,11 @@ public class UnknownElement extends Task { * * @param line The line of output to log. Should not be null. */ - protected void handleOutput(String line, boolean terminated) { + protected void handleFlush(String line) { if (realThing instanceof Task) { - ((Task) realThing).handleOutput(line, terminated); + ((Task) realThing).handleFlush(line); } else { - super.handleOutput(line, terminated); + super.handleFlush(line); } } @@ -188,11 +188,11 @@ public class UnknownElement extends Task { * * @param line The error line to log. Should not be null. */ - protected void handleErrorOutput(String line, boolean terminated) { + protected void handleErrorFlush(String line) { if (realThing instanceof Task) { - ((Task) realThing).handleErrorOutput(line, terminated); + ((Task) realThing).handleErrorOutput(line); } else { - super.handleErrorOutput(line, terminated); + super.handleErrorOutput(line); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/Ant.java b/src/main/org/apache/tools/ant/taskdefs/Ant.java index 5cbffe269..3851f8e52 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Ant.java +++ b/src/main/org/apache/tools/ant/taskdefs/Ant.java @@ -288,7 +288,7 @@ public class Ant extends Task { * * @since Ant 1.5 */ - protected void handleOutput(String line) { + public void handleOutput(String line) { if (newProject != null) { newProject.demuxOutput(line, false); } else { @@ -299,13 +299,13 @@ public class Ant extends Task { /** * Pass output sent to System.out to the new project. * - * @since Ant 1.6 + * @since Ant 1.5.2 */ - protected void handleOutput(String line, boolean terminated) { + public void handleFlush(String line) { if (newProject != null) { - newProject.demuxOutput(line, false, terminated); + newProject.demuxFlush(line, false); } else { - super.handleOutput(line, terminated); + super.handleFlush(line); } } @@ -314,7 +314,7 @@ public class Ant extends Task { * * @since Ant 1.5 */ - protected void handleErrorOutput(String line) { + public void handleErrorOutput(String line) { if (newProject != null) { newProject.demuxOutput(line, true); } else { @@ -325,13 +325,13 @@ public class Ant extends Task { /** * Pass output sent to System.err to the new project. * - * @since Ant 1.6 + * @since Ant 1.5.2 */ - protected void handleErrorOutput(String line, boolean terminated) { + public void handleErrorFlush(String line) { if (newProject != null) { - newProject.demuxOutput(line, true, terminated); + newProject.demuxFlush(line, true); } else { - super.handleErrorOutput(line, terminated); + super.handleErrorFlush(line); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/CallTarget.java b/src/main/org/apache/tools/ant/taskdefs/CallTarget.java index 7bbea21b1..4c5d2701e 100644 --- a/src/main/org/apache/tools/ant/taskdefs/CallTarget.java +++ b/src/main/org/apache/tools/ant/taskdefs/CallTarget.java @@ -188,13 +188,13 @@ public class CallTarget extends Task { /** * Pass output sent to System.out to the new project. * - * @since Ant 1.6 + * @since Ant 1.5.2 */ - protected void handleOutput(String line, boolean terminated) { + public void handleFlush(String line) { if (callee != null) { - callee.handleOutput(line, terminated); + callee.handleFlush(line); } else { - super.handleOutput(line, terminated); + super.handleFlush(line); } } @@ -214,13 +214,13 @@ public class CallTarget extends Task { /** * Pass output sent to System.err to the new project. * - * @since Ant 1.6 + * @since Ant 1.5.2 */ - protected void handleErrorOutput(String line, boolean terminated) { + public void handleErrorFlush(String line) { if (callee != null) { - callee.handleErrorOutput(line, terminated); + callee.handleErrorFlush(line); } else { - super.handleErrorOutput(line, terminated); + super.handleErrorFlush(line); } } } diff --git a/src/main/org/apache/tools/ant/taskdefs/Java.java b/src/main/org/apache/tools/ant/taskdefs/Java.java index 845a5f33b..f65820f10 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Java.java +++ b/src/main/org/apache/tools/ant/taskdefs/Java.java @@ -376,17 +376,13 @@ public class Java extends Task { /** * Pass output sent to System.out to specified output file. * - * @since Ant 1.6 + * @since Ant 1.5.2 */ - protected void handleOutput(String line, boolean terminated) { + protected void handleFlush(String line) { if (outStream != null) { - if (terminated) { - outStream.println(line); - } else { - outStream.print(line); - } + outStream.print(line); } else { - super.handleOutput(line, terminated); + super.handleFlush(line); } } @@ -406,17 +402,13 @@ public class Java extends Task { /** * Pass output sent to System.err to specified output file. * - * @since Ant 1.6 + * @since Ant 1.5.2 */ - protected void handleErrorOutput(String line, boolean terminated) { + protected void handleErrorFlush(String line) { if (outStream != null) { - if (terminated) { - outStream.println(line); - } else { - outStream.print(line); - } + outStream.println(line); } else { - super.handleErrorOutput(line, terminated); + super.handleErrorOutput(line); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java index 2afc74fd2..016784677 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java @@ -717,16 +717,16 @@ public class JUnitTask extends Task { * Pass output sent to System.out to the TestRunner so it can * collect ot for the formatters. * - * @since Ant 1.6 + * @since Ant 1.5.2 */ - protected void handleOutput(String line, boolean terminated) { + protected void handleFlush(String line) { if (runner != null) { - runner.handleOutput(line, terminated); + runner.handleFlush(line); if (showOutput) { - super.handleOutput(line, terminated); + super.handleFlush(line); } } else { - super.handleOutput(line, terminated); + super.handleFlush(line); } } @@ -736,7 +736,7 @@ public class JUnitTask extends Task { * * @since Ant 1.5 */ - protected void handleErrorOutput(String line) { + public void handleErrorOutput(String line) { if (runner != null) { runner.handleErrorOutput(line); if (showOutput) { @@ -752,16 +752,16 @@ public class JUnitTask extends Task { * Pass output sent to System.err to the TestRunner so it can * collect ot for the formatters. * - * @since Ant 1.6 + * @since Ant 1.5.2 */ - protected void handleErrorOutput(String line, boolean terminated) { + public void handleErrorFlush(String line) { if (runner != null) { - runner.handleErrorOutput(line, terminated); + runner.handleErrorFlush(line); if (showOutput) { - super.handleErrorOutput(line, terminated); + super.handleErrorFlush(line); } } else { - super.handleErrorOutput(line, terminated); + super.handleErrorFlush(line); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java index 59bb7783d..03186713c 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java @@ -416,23 +416,15 @@ public class JUnitTestRunner implements TestListener { } } - protected void handleOutput(String line, boolean terminated) { + protected void handleFlush(String line) { if (systemOut != null) { - if (terminated) { - systemOut.println(line); - } else { - systemOut.print(line); - } + systemOut.print(line); } } - protected void handleErrorOutput(String line, boolean terminated) { + protected void handleErrorFlush(String line) { if (systemError != null) { - if (terminated) { - systemError.println(line); - } else { - systemError.print(line); - } + systemError.print(line); } }