import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
-import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
IOException ioException = null;
try {
process = processBuilder.start();
- final Callable<Void> errorGobbler = new StreamGobbler(
- process.getErrorStream(), errRedirect);
- final Callable<Void> outputGobbler = new StreamGobbler(
- process.getInputStream(), outRedirect);
- executor.submit(errorGobbler);
- executor.submit(outputGobbler);
+ executor.execute(
+ new StreamGobbler(process.getErrorStream(), errRedirect));
+ executor.execute(
+ new StreamGobbler(process.getInputStream(), outRedirect));
OutputStream outputStream = process.getOutputStream();
if (inRedirect != null) {
- new StreamGobbler(inRedirect, outputStream)
- .call();
+ new StreamGobbler(inRedirect, outputStream).copy();
}
try {
outputStream.close();
* streams.
* </p>
*/
- private static class StreamGobbler implements Callable<Void> {
+ private static class StreamGobbler implements Runnable {
private InputStream in;
private OutputStream out;
this.out = output;
}
- public Void call() throws IOException {
+ public void run() {
+ try {
+ copy();
+ } catch (IOException e) {
+ // Do nothing on read failure; leave streams open.
+ }
+ }
+
+ void copy() throws IOException {
boolean writeFailure = false;
byte buffer[] = new byte[4096];
int readBytes;
}
}
}
- return null;
}
}
}