From c25de77022775eedda72e9eb162b2397aee042a8 Mon Sep 17 00:00:00 2001 From: Matthew Jason Benson Date: Tue, 27 Apr 2004 18:14:54 +0000 Subject: [PATCH] Move Process stream closure into a new public static method, closeStreams(Process). PR: 28565 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276419 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tools/ant/taskdefs/Execute.java | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/Execute.java b/src/main/org/apache/tools/ant/taskdefs/Execute.java index d37ba861f..51bc4654f 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Execute.java +++ b/src/main/org/apache/tools/ant/taskdefs/Execute.java @@ -475,6 +475,7 @@ public class Execute { watchdog.stop(); } streamHandler.stop(); + closeStreams(process); if (watchdog != null) { watchdog.checkException(); @@ -536,13 +537,6 @@ public class Execute { setExitValue(process.exitValue()); } catch (InterruptedException e) { process.destroy(); - } finally { - try { - process.getInputStream().close(); - process.getOutputStream().close(); - process.getErrorStream().close(); - } catch (IOException eyeOhEx) { - } } } @@ -659,6 +653,25 @@ public class Execute { } } + /** + * Close the streams belonging to the given Process. + * @param process the Process. + */ + 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) { + } + } + /** * This method is VMS specific and used by getProcEnvironment(). *