DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21636>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21636

Java task wraps output by default

           Summary: Java task wraps output by default
           Product: Ant
           Version: 1.6Alpha (nightly)
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Core tasks
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


The Java task when used with an 'output' attribute will wrap the output.  This
can lead to corruption/invalid output from otherwise well-behaving Java programs
that emit all data on long lines without a newline.  The output will have
newlines added throughout in incorrect locations.

A task snippet:

<java classname="LongLine" output="longline.txt" />

where LongLine's main class will emit something greater than 4k without a new
line to System.out.  The output file longline.txt will now contain newlines in
places not originally requested.

The output from the above task would be different from:

java LongLine > longline.txt

It seems that the Redirector class will always print newlines.  A partial fix is
as follows:

--- src/main/org/apache/tools/ant/taskdefs/Redirector.java      Tue Jul 15 
21:59:37 2003
+++ src/main/org/apache/tools/ant/taskdefs/Redirector.java.new  Tue Jul 15
21:58:28 2003
@@ -365,7 +365,7 @@
         if (outPrintStream == null) {
             outPrintStream = new PrintStream(outputStream);
         }
-        outPrintStream.println(line);
+        outPrintStream.print(line);
     }
 
     /**

This is definitely not an ideal solution because now no newlines will be emitted
to the file.  This isn't right either, but solves my immediate problem.

This problem also exists in Ant 1.5.3 which has the output code back in Java
taskdef file.

I'll leave it to people who know Ant better than I for a more complete solution.
 If you need a more precise reproduction case, please let me know, but it's
fairly straightforward to reproduce (IMHO).

Thanks!

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to