ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jlcarpen...@household.com
Subject Re: Reentry problems with CVS task (mabye Execute task used by composition)
Date Sat, 17 Aug 2002 00:23:01 GMT

In case your wondering, I tried a workaround of using a whole new CVS
object but it still hung on the second pass.

James Lee Carpenter
Software Engineer
Household Technical Services
6602 Convoy Court
San Diego, CA 92111

ph: 858-609-2461
email: jlcarpenter@household.com


                                                                                         
                                        
                                                                                         
                                        
                           jlcarpenter@household       To:     "Ant Developers List" <ant-dev@jakarta.apache.org>
                
                           .com                        cc:                               
                                        
                                                       Subject:       Reentry problems with
CVS task (mabye Execute task used by  
                           08/16/2002 05:16 PM                 composition)              
                                        
                           Please respond to                                             
                                        
                           "Ant Developers List"                                         
                                        
                                                                                         
                                        
                                                                                         
                                        




I am writting a task which makes use of a utility with the following
method.  The basic idea is that a CVS object is configured with a
PumpStreamHandler (implements the ExecuteStreamHandler interface) created
with PipedInputOutputStream and PipedOutputStream instances.  A later
method wraps
the PipedInputStream instance returned by the createCvsLogStream method in
a BufferedReader and proceeds to read the results of the cvs log command.
When the method with the BufferedReader is done it calls the close method
on both the BufferedReader and the PipedInputStream instances.

This works fine on the first pass, but on the second pass hangs indefintely
at the cvs.execute() command.  If one walks down deeply into the
execute method, one finds the hanging occurs when the Java13CommandLauncher
inner class of org.apache.tools.ant.taskdefs.Execute calls the line:
_execWithCWD.invoke(Runtime.getRuntime(), arguments);

If one inspects the Java13CommandLauncher class variables one finds:
_execWithCWD = Runtime.class.getMethod("exec",
                new Class[] {String[].class, String[].class, File.class});


Unfortunately, I don't know enough to understand why this is hanging.
Remember, that it is just fine on the first pass, but has problems on the
second.  I suspect I may be falling ito a common trap and don't recognize
it.

Can anyone provide some guidance?

      private static PipedInputStream createCvsLogStream(
            Cvs cvs,
            String guideFile)
            throws BuildException {

            //Prepare an ExecuteStreamHandler for CVS
            PipedOutputStream pipedOS = new PipedOutputStream();
            PipedInputStream pipedIS;
            try {
                  pipedIS = new PipedInputStream(pipedOS);
            } catch (IOException ex) {
                  throw new BuildException("Encountered problems creating a
piped input stream.");
            }

            ExecuteStreamHandler exeSH = new PumpStreamHandler(pipedOS);

            //Configure cvs
            cvs.setExecuteStreamHandler(exeSH);
            cvs.setCommand("log " + guideFile);
            cvs.setFailOnError(true);
            cvs.execute();

            //Flush and close piped output stream
            try {
                  pipedOS.flush();
            } catch (IOException ex) {
                  throw new BuildException(
                        "Had problems flushing piped output stream "
                              + "used in CvsUtility.createCvsLogStream");
            }
            try {
                  pipedOS.close();
            } catch (IOException ex) {
                  throw new BuildException(
                        "Had problems closing piped output stream "
                              + "used in CvsUtility.createCvsLogStream");
            }

            return pipedIS;
      }

James Lee Carpenter
Software Engineer
Household Technical Services
6602 Convoy Court
San Diego, CA 92111

ph: 858-609-2461
email: jlcarpenter@household.com



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







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


Mime
View raw message