You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Will Wang <ww...@seebeyond.com> on 2004/07/13 23:10:03 UTC

outputStream and errorStream in AbstractCvsTask

Hi, this is my first attempt to submit a fix to a open source project.  I've search thru the archive but could not find anything related.  Please forgive me if I'm missing anything.

I have a custom task (CvsMergeTask) extending AbstractCvsTask.  It reads thru the entries in changlog.xml (from ChangeLogTask) and generates a series of cvs commands and insert them into vecCommandlines using addConfiguredCommandline(Commandline).

The problem was with output of the commands.  When directing output of the commands to a file using the "output" and "error" attributes, only the output of the 1st command executed was redirected - the output from the rest of the cvs commands are lost.  The reason is because for each cvs commands in vecCommandlines, runCommand(Commandline) is executed and outputStream and errorStream are closed in the finally block in runCommand(Commandline).  Thus, right after runCommand(Commandline) is called for the 1st command in vecCommandlines, the outputStream and errorStream are closed and never re-opened, and therefore unavaliable to the subsequent commands when runCommand(Commandline) is called.

The solution I have is to moved the close() call of both outputStream and errorStream to the finally block execute() method. (Patch attached).  The reason is that "only close the outputStream and errorStream after all commands are executed."  Let me know what you think!  :)

Thanks,
Will