ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Will Wang" <>
Subject outputStream and errorStream in AbstractCvsTask
Date Tue, 13 Jul 2004 21:10:03 GMT
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!  :)


View raw message