}
private void doRun(final Connection<Object> connection, Stoppable serverControl) {
ExecutionListenerImpl executionListener = new ExecutionListenerImpl();
try {
LoggingOutputInternal loggingOutput = loggingServices.get(LoggingOutputInternal.class);
OutputEventListener listener = new OutputEventListener() {
public void onOutput(OutputEvent event) {
connection.dispatch(event);
}
};
// Perform as much as possible of the interaction while the logging is routed to the client
loggingOutput.addOutputEventListener(listener);
try {
doRunWithLogging(connection, serverControl, executionListener);
} finally {
loggingOutput.removeOutputEventListener(listener);
}
} catch (Throwable throwable) {
LOGGER.error("Could not execute build.", throwable);
executionListener.onFailure(throwable);
}