ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 30097] New: - AbstractCvsTask prematurely closes its outputStream and errorStream
Date Wed, 14 Jul 2004 07:50:47 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=30097>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=30097

AbstractCvsTask prematurely closes its outputStream and errorStream

           Summary: AbstractCvsTask prematurely closes its outputStream and
                    errorStream
           Product: Ant
           Version: 1.6.1
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Core tasks
        AssignedTo: dev@ant.apache.org
        ReportedBy: telerice@yahoo.com


(I apologize if I'm being redundant.  I've posted this issue to the dev list
already, but then I thought maybe that was not the best way to submit bug fix.)

AbstractCvsTask holds a Vector of Commandlines (vecCommandlines).  The execute()
method iterates thru the Commandlines and calls runCommand(Commandline).

runCommand(Commandline) redirects the command output to outputStream and
errorStream but closes them before returning.  So if vecCommandlines holds more
than 1 command, then any subsquent call to runCommand(Commandline) after the 1st
call will cause the command output to be redirected to the closed outputStreams
and errorStream.  (The IOExceptions caused by writing to closed streams are
swallowed by the empty catch clause in StreamPumper).

The patch here moves the closing call of outputStream and errorStream from the
end of runCommand(Commandline) method to the end of execute() method.  The
rationale here is to only close the streams after all commands in
vecCommandlines are executed.

Index: AbstractCvsTask.java
===================================================================
RCS file:
/home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/AbstractCvsTask.java,v
retrieving revision 1.34
diff -u -r1.34 AbstractCvsTask.java
--- AbstractCvsTask.java	14 Apr 2004 15:42:06 -0000	1.34
+++ AbstractCvsTask.java	14 Jul 2004 07:41:35 -0000
@@ -365,21 +365,6 @@
             } else {
                 log("Caught exception: " + e.getMessage(), Project.MSG_WARN);
             }
-        } finally {
-            if (outputStream != null) {
-                try {
-                    outputStream.close();
-                } catch (IOException e) {
-                    //ignore
-                }
-            }
-            if (errorStream != null) {
-                try {
-                    errorStream.close();
-                } catch (IOException e) {
-                    //ignore
-                }
-            }
         }
     }
 
@@ -413,6 +398,21 @@
                 removeCommandline(cloned);
             }
             setCommand(savedCommand);
+
+			if (outputStream != null) {
+			    try {
+			        outputStream.close();
+			    } catch (IOException e) {
+			        //ignore
+			    }
+			}
+			if (errorStream != null) {
+			    try {
+			        errorStream.close();
+			    } catch (IOException e) {
+			        //ignore
+			    }
+			}
         }
     }

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message