You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by jl...@household.com on 2002/08/17 02:16:05 UTC

Reentry problems with CVS task (mabye Execute task used by composition)

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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>