mbenson     2004/04/27 11:14:54

  Modified:    src/main/org/apache/tools/ant/taskdefs Execute.java
  Log:
  Move Process stream closure into a new public static method,
  closeStreams(Process).
  PR: 28565
  
  Revision  Changes    Path
  1.81      +21 -8     ant/src/main/org/apache/tools/ant/taskdefs/Execute.java
  
  Index: Execute.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Execute.java,v
  retrieving revision 1.80
  retrieving revision 1.81
  diff -u -r1.80 -r1.81
  --- Execute.java      27 Apr 2004 15:30:56 -0000      1.80
  +++ Execute.java      27 Apr 2004 18:14:54 -0000      1.81
  @@ -475,6 +475,7 @@
                   watchdog.stop();
               }
               streamHandler.stop();
  +            closeStreams(process);
   
               if (watchdog != null) {
                   watchdog.checkException();
  @@ -536,13 +537,6 @@
               setExitValue(process.exitValue());
           } catch (InterruptedException e) {
               process.destroy();
  -        } finally {
  -            try {
  -                process.getInputStream().close();
  -                process.getOutputStream().close();
  -                process.getErrorStream().close();
  -            } catch (IOException eyeOhEx) {
  -            }
           }
       }
   
  @@ -656,6 +650,25 @@
           } catch (java.io.IOException exc) {
               throw new BuildException("Could not launch " + cmdline[0] + ": "
                   + exc, task.getLocation());
  +        }
  +    }
  +
  +    /**
  +     * Close the streams belonging to the given Process.
  +     * @param process   the <CODE>Process</CODE>.
  +     */
  +    public static void closeStreams(Process process) {
  +        try {
  +            process.getInputStream().close();
  +        } catch (IOException eyeOhEx) {
  +        }
  +        try {
  +            process.getOutputStream().close();
  +        } catch (IOException eyeOhEx) {
  +        }
  +        try {
  +            process.getErrorStream().close();
  +        } catch (IOException eyeOhEx) {
           }
       }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to