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
Index: AbstractCvsTask.java
===================================================================
RCS file:
/home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/AbstractCvsTask.java,v
retrieving revision 1.34
diff -r1.34 AbstractCvsTask.java
368,383c368
< } finally {
< if (outputStream != null) {
< try {
< outputStream.close();
< } catch (IOException e) {
< //ignore
< }
< }
< if (errorStream != null) {
< try {
< errorStream.close();
< } catch (IOException e) {
< //ignore
< }
< }
< }
---
> }
415a401,415
>
> if (outputStream != null) {
> try {
> outputStream.close();
> } catch (IOException e) {
> //ignore
> }
> }
> if (errorStream != null) {
> try {
> errorStream.close();
> } catch (IOException e) {
> //ignore
> }
> }
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]