Source:
public ICommandResult executeCommand(final String command, final IProgressMonitor monitor) throws ExecutionException { if (fConnection.isOpen()) { FutureTask<CommandResult> future = new FutureTask<>(new Callable<CommandResult>() { @Override public CommandResult call() throws IOException, CancellationException { synchronized (fConnection) { IRemoteProcessBuilder processBuilder = fConnection.getProcessBuilder(splitCommand(command)); IRemoteProcess process= processBuilder.start(); InputReader stdout= new InputReader(process.getInputStream()); InputReader stderr= new InputReader(process.getErrorStream()); try { stdout.waitFor(); stderr.waitFor(); int result = process.waitFor(); String output= stdout.getOutput(); String error= null; if (result != 0) { error= stderr.getOutput(); if (error.length() == 0) { error= output; } } return new CommandResult(result, splitLines(output), splitLines(error)); } catch (InterruptedException e) { return new CommandResult(1, new String[0], new String[] {e.getMessage()}); } finally { stdout.stop(); stderr.stop(); } } } private String[] splitLines(String output) { if (output == null) { return null; } return output.split("\\r?\\n"); } private String[] splitCommand(String shellCommand) { return shellCommand.trim().split("\\s+"); } }); fExecutor.execute(future); try { return future.get(ControlPreferences.getInstance().getCommandTimeout(), TimeUnit.SECONDS); } catch (java.util.concurrent.ExecutionException ex) { throw new ExecutionException(Messages.TraceControl_ExecutionFailure, ex); } catch (InterruptedException ex) { throw new ExecutionException(Messages.TraceControl_ExecutionCancelled, ex); } catch (TimeoutException ex) { throw new ExecutionException(Messages.TraceControl_ExecutionTimeout, ex); } } throw new ExecutionException(Messages.TraceControl_ShellNotConnected, null); }

Target:
public ICommandResult executeCommand(final String command, final IProgressMonitor monitor) throws ExecutionException { if (fConnection.isOpen()) { FutureTask<CommandResult> future = new FutureTask<>(new Callable<CommandResult>() { @Override public CommandResult call() throws IOException, CancellationException { if (monitor == null || !monitor.isCanceled()) { final boolean isRSE = RSE_ADAPTER_ID.equals(fConnection.getRemoteServices().getId()); IRemoteProcess process = startRemoteProcess(isRSE, command); InputReader stdout = new InputReader(process.getInputStream()); InputReader stderr = new InputReader(process.getErrorStream()); try { stdout.waitFor(monitor); stderr.waitFor(monitor); if (monitor == null || !monitor.isCanceled()) { return createResult(isRSE, process.waitFor(), stdout.toString(), stderr.toString()); } } catch (OperationCanceledException e) { } catch (InterruptedException e) { return new CommandResult(1, new String[0], new String[] {e.getMessage()}); } finally { stdout.stop(); stderr.stop(); process.destroy(); } } return new CommandResult(1, new String[0], new String[] {"cancelled"}); } }); fExecutor.execute(future); try { return future.get(ControlPreferences.getInstance().getCommandTimeout(), TimeUnit.SECONDS); } catch (java.util.concurrent.ExecutionException ex) { throw new ExecutionException(Messages.TraceControl_ExecutionFailure, ex); } catch (InterruptedException ex) { throw new ExecutionException(Messages.TraceControl_ExecutionCancelled, ex); } catch (TimeoutException ex) { throw new ExecutionException(Messages.TraceControl_ExecutionTimeout, ex); } finally { future.cancel(true); } } throw new ExecutionException(Messages.TraceControl_ShellNotConnected, null); }