From f0021948fa782c4a2c44ce9d2dbdaef7998c90ab Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Tue, 27 Jun 2017 16:44:28 +0300 Subject: [PATCH] [platform] GeneralCommandLine API fix (IDEA-CR-19850) --- .../configurations/GeneralCommandLine.java | 17 ++++++----------- .../execution/GeneralCommandLineTest.java | 3 +-- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/platform/platform-api/src/com/intellij/execution/configurations/GeneralCommandLine.java b/platform/platform-api/src/com/intellij/execution/configurations/GeneralCommandLine.java index fded2de40bbe..7d82d0ad1966 100644 --- a/platform/platform-api/src/com/intellij/execution/configurations/GeneralCommandLine.java +++ b/platform/platform-api/src/com/intellij/execution/configurations/GeneralCommandLine.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -98,7 +98,7 @@ public class GeneralCommandLine implements UserDataHolder { private final ParametersList myProgramParams = new ParametersList(); private Charset myCharset = CharsetToolkit.getDefaultSystemCharset(); private boolean myRedirectErrorStream = false; - private ProcessBuilder.Redirect myInputRedirect; + private File myInputFile; private Map myUserData; public GeneralCommandLine() { } @@ -282,14 +282,9 @@ public class GeneralCommandLine implements UserDataHolder { withRedirectErrorStream(redirectErrorStream); } - @Nullable - public ProcessBuilder.Redirect getInputRedirect() { - return myInputRedirect; - } - @NotNull - public GeneralCommandLine withInputRedirect(@Nullable ProcessBuilder.Redirect inputRedirect) { - myInputRedirect = inputRedirect; + public GeneralCommandLine withInput(@Nullable File file) { + myInputFile = file; return this; } @@ -414,8 +409,8 @@ public class GeneralCommandLine implements UserDataHolder { setupEnvironment(builder.environment()); builder.directory(myWorkDirectory); builder.redirectErrorStream(myRedirectErrorStream); - if (myInputRedirect != null) { - builder.redirectInput(myInputRedirect); + if (myInputFile != null) { + builder.redirectInput(ProcessBuilder.Redirect.from(myInputFile)); } return builder.start(); } diff --git a/platform/platform-tests/testSrc/com/intellij/execution/GeneralCommandLineTest.java b/platform/platform-tests/testSrc/com/intellij/execution/GeneralCommandLineTest.java index f87c889a88ce..ec9e17296362 100644 --- a/platform/platform-tests/testSrc/com/intellij/execution/GeneralCommandLineTest.java +++ b/platform/platform-tests/testSrc/com/intellij/execution/GeneralCommandLineTest.java @@ -367,8 +367,7 @@ public class GeneralCommandLineTest { "@echo off\n" + "findstr \"^\"\n", "#!/bin/sh\n" + "cat\n"); try { - GeneralCommandLine commandLine = createCommandLine(script.getPath()); - commandLine.withInputRedirect(ProcessBuilder.Redirect.from(input)); + GeneralCommandLine commandLine = createCommandLine(script.getPath()).withInput(input); String output = execAndGetOutput(commandLine); assertEquals(content, StringUtil.convertLineSeparators(output)); }