From 1d32083bd084fa8d055845927f7858d08832b2cc Mon Sep 17 00:00:00 2001 From: Steve Loughran Date: Fri, 8 Sep 2006 14:22:58 +0000 Subject: [PATCH] use a buffered file in reporting. Added a note to tell people not to switch to ClasspathUtils because the forking junit tests promptly fail. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@441510 13f79535-47bb-0310-9956-ffa450edef68 --- .../ant/taskdefs/optional/junit/FormatterElement.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/FormatterElement.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/FormatterElement.java index d734fd3e7..64d383414 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/FormatterElement.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/FormatterElement.java @@ -21,6 +21,8 @@ package org.apache.tools.ant.taskdefs.optional.junit; import java.io.File; import java.io.FileOutputStream; import java.io.OutputStream; +import java.io.BufferedOutputStream; + import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Task; import org.apache.tools.ant.types.EnumeratedAttribute; @@ -202,7 +204,9 @@ public class FormatterElement { if (classname == null) { throw new BuildException("you must specify type or classname"); } - + //although this code appears to duplicate that of ClasspathUtils.newInstance, + //we cannot use that because this formatter may run in a forked process, + //without that class. Class f = null; try { if (loader == null) { @@ -230,12 +234,11 @@ public class FormatterElement { + " is not a JUnitResultFormatter"); } JUnitTaskMirror.JUnitResultFormatterMirror r = (JUnitTaskMirror.JUnitResultFormatterMirror) o; - if (useFile && outFile != null) { try { - out = new FileOutputStream(outFile); + out = new BufferedOutputStream(new FileOutputStream(outFile)); } catch (java.io.IOException e) { - throw new BuildException(e); + throw new BuildException("Unable to open file " + outFile, e); } } r.setOutput(out);