private final long watcherDelayMs;
private ProcessMonitor process;
- private StreamGobbler gobbler;
+ private StreamGobbler stdOutGobbler;
+ private StreamGobbler stdErrGobbler;
private final StopWatcher stopWatcher;
private final EventWatcher eventWatcher;
// keep flag so that the operational event is sent only once
lifecycle.tryToMoveTo(Lifecycle.State.STOPPED);
throw e;
}
- this.gobbler = new StreamGobbler(process.getInputStream(), processId.getKey());
- this.gobbler.start();
+ this.stdOutGobbler = new StreamGobbler(process.getInputStream(), processId.getKey());
+ this.stdOutGobbler.start();
+ this.stdErrGobbler = new StreamGobbler(process.getErrorStream(), processId.getKey());
+ this.stdErrGobbler.start();
this.stopWatcher.start();
this.eventWatcher.start();
// Could be improved by checking the status "up" in shared memory.
waitForDown();
process.closeStreams();
}
- if (gobbler != null) {
- StreamGobbler.waitUntilFinish(gobbler);
- gobbler.interrupt();
+ if (stdOutGobbler != null) {
+ StreamGobbler.waitUntilFinish(stdOutGobbler);
+ stdOutGobbler.interrupt();
+ }
+ if (stdErrGobbler != null) {
+ StreamGobbler.waitUntilFinish(stdErrGobbler);
+ stdErrGobbler.interrupt();
}
lifecycle.tryToMoveTo(Lifecycle.State.STOPPED);
}
private final CountDownLatch alive = new CountDownLatch(1);
private final InputStream inputStream = mock(InputStream.class, Mockito.RETURNS_MOCKS);
+ private final InputStream errorStream = mock(InputStream.class, Mockito.RETURNS_MOCKS);
private boolean streamsClosed = false;
private boolean operational = false;
private boolean askedForRestart = false;
return inputStream;
}
+ @Override
+ public InputStream getErrorStream() {
+ return errorStream;
+ }
+
@Override
public void closeStreams() {
streamsClosed = true;