|
|
@@ -1108,19 +1108,23 @@ public abstract class FS { |
|
|
|
new StreamGobbler(process.getErrorStream(), errRedirect)); |
|
|
|
executor.execute( |
|
|
|
new StreamGobbler(process.getInputStream(), outRedirect)); |
|
|
|
@SuppressWarnings("resource") // Closed in the finally block |
|
|
|
OutputStream outputStream = process.getOutputStream(); |
|
|
|
if (inRedirect != null) { |
|
|
|
new StreamGobbler(inRedirect, outputStream).copy(); |
|
|
|
} |
|
|
|
try { |
|
|
|
outputStream.close(); |
|
|
|
} catch (IOException e) { |
|
|
|
// When the process exits before consuming the input, the OutputStream |
|
|
|
// is replaced with the null output stream. This null output stream |
|
|
|
// throws IOException for all write calls. When StreamGobbler fails to |
|
|
|
// flush the buffer because of this, this close call tries to flush it |
|
|
|
// again. This causes another IOException. Since we ignore the |
|
|
|
// IOException in StreamGobbler, we also ignore the exception here. |
|
|
|
if (inRedirect != null) { |
|
|
|
new StreamGobbler(inRedirect, outputStream).copy(); |
|
|
|
} |
|
|
|
} finally { |
|
|
|
try { |
|
|
|
outputStream.close(); |
|
|
|
} catch (IOException e) { |
|
|
|
// When the process exits before consuming the input, the OutputStream |
|
|
|
// is replaced with the null output stream. This null output stream |
|
|
|
// throws IOException for all write calls. When StreamGobbler fails to |
|
|
|
// flush the buffer because of this, this close call tries to flush it |
|
|
|
// again. This causes another IOException. Since we ignore the |
|
|
|
// IOException in StreamGobbler, we also ignore the exception here. |
|
|
|
} |
|
|
|
} |
|
|
|
return process.waitFor(); |
|
|
|
} catch (IOException e) { |