diff --git a/.idea/libraries/pty4j.xml b/.idea/libraries/pty4j.xml index c35366324432..c5cfe1a7a7cc 100644 --- a/.idea/libraries/pty4j.xml +++ b/.idea/libraries/pty4j.xml @@ -1,7 +1,7 @@ - + diff --git a/build/scripts/libLicenses.gant b/build/scripts/libLicenses.gant index 64acdcd33ff0..1c497a2fb62d 100644 --- a/build/scripts/libLicenses.gant +++ b/build/scripts/libLicenses.gant @@ -268,7 +268,7 @@ libraryLicense(name: "asm-4.0-all", libraryName: "asm-4.0-all", version: "4.0", libraryLicense(name: "jsr305", libraryName: "jsr305", version: "snapshot", license: "BSD", url: "http://code.google.com/p/jsr-305/", licenseUrl: "http://code.google.com/p/jsr-305/source/browse/trunk/ri/LICENSE") libraryLicense(name: "jzlib", libraryName: "jzlib", version: "1.1.1", license: "BSD", url: "http://www.jcraft.com/jzlib/", licenseUrl: "http://www.jcraft.com/jzlib/LICENSE.txt") libraryLicense(name: "PureJavaComm", libraryName: "purejavacomm", version: "0.0.16", license: "BSD", url: "http://www.sparetimelabs.com/purejavacomm") -libraryLicense(name: "pty4j", libraryName: "pty4j", version: "0.2", license: "Eclipse Public License v1.0", url: "https://github.com/traff/pty4j") +libraryLicense(name: "pty4j", libraryName: "pty4j", version: "0.4", license: "Eclipse Public License v1.0", url: "https://github.com/traff/pty4j") libraryLicense(name: "JediTerm", libraryName: "jediterm-pty", version: "0.2", license: "LGPL 2", url: "https://github.com/traff/jediterm", licenseUrl: "https://github.com/traff/jediterm/blob/master/COPYING") libraryLicense(name: "bouncy-castle", version: "1.48", license: "MIT License", url: "http://bouncycastle.org", licenseUrl: "http://bouncycastle.org/licence.html") libraryLicense(name: "kXML2", libraryName: "kxml2", version: "2.3.0", license: "BSD", url: "http://sourceforge.net/projects/kxml/") diff --git a/lib/pty4j-0.3.jar b/lib/pty4j-0.3.jar deleted file mode 100644 index d1345bc70264..000000000000 Binary files a/lib/pty4j-0.3.jar and /dev/null differ diff --git a/lib/required_for_dist.txt b/lib/required_for_dist.txt index 9cbd677cabbb..5eedb6dc43c5 100644 --- a/lib/required_for_dist.txt +++ b/lib/required_for_dist.txt @@ -53,7 +53,7 @@ oromatcher.jar picocontainer.jar protobuf-2.5.0.jar proxy-vole_20131209.jar -pty4j-0.3.jar +pty4j-0.4.jar purejavacomm.jar resolver.jar rhino-js-1_7R4.jar diff --git a/platform/util/src/com/intellij/execution/process/BaseOSProcessHandler.java b/platform/util/src/com/intellij/execution/process/BaseOSProcessHandler.java index ce4561d3806d..3156819bd7b6 100644 --- a/platform/util/src/com/intellij/execution/process/BaseOSProcessHandler.java +++ b/platform/util/src/com/intellij/execution/process/BaseOSProcessHandler.java @@ -69,6 +69,14 @@ public class BaseOSProcessHandler extends ProcessHandler implements TaskExecutor return false; } + /** + * Override this method to read process output and error streams in blocking mode + * @return true to read non-blocking but sleeping, false for blocking read + */ + protected boolean useNonBlockingRead() { + return true; + } + protected boolean processHasSeparateErrorStream() { return true; } @@ -117,7 +125,13 @@ public class BaseOSProcessHandler extends ProcessHandler implements TaskExecutor } private BaseDataReader.SleepingPolicy getPolicy() { - return useAdaptiveSleepingPolicyWhenReadingOutput() ? new AdaptiveSleepingPolicy() : BaseDataReader.SleepingPolicy.SIMPLE; + if (useNonBlockingRead()) { + return useAdaptiveSleepingPolicyWhenReadingOutput() ? new AdaptiveSleepingPolicy() : BaseDataReader.SleepingPolicy.SIMPLE; + } + else { + //use blocking read policy + return BaseDataReader.SleepingPolicy.BLOCKING; + } } @NotNull @@ -143,10 +157,10 @@ public class BaseOSProcessHandler extends ProcessHandler implements TaskExecutor } private Reader createInputStreamReader(InputStream streamToRead) { - final Charset charset = getCharset(); + Charset charset = getCharset(); if (charset == null) { // use default charset - return new InputStreamReader(streamToRead); + charset = Charset.defaultCharset(); } return new InputStreamReader(streamToRead, charset); } diff --git a/platform/util/src/com/intellij/util/io/BaseDataReader.java b/platform/util/src/com/intellij/util/io/BaseDataReader.java index 5b0226667edd..cfdd5569cd66 100644 --- a/platform/util/src/com/intellij/util/io/BaseDataReader.java +++ b/platform/util/src/com/intellij/util/io/BaseDataReader.java @@ -62,6 +62,16 @@ public abstract class BaseDataReader { } }; + SleepingPolicy BLOCKING = new SleepingPolicy() { + @Override + public int getTimeToSleep(boolean wasActive) { + // in blocking mode we need to sleep only when we have reached end of the stream + // so it can be a long sleeping + return 50; + } + }; + + int getTimeToSleep(boolean wasActive); } diff --git a/platform/util/src/com/intellij/util/io/BaseOutputReader.java b/platform/util/src/com/intellij/util/io/BaseOutputReader.java index 47f7b7bf73e0..f1035858aad4 100644 --- a/platform/util/src/com/intellij/util/io/BaseOutputReader.java +++ b/platform/util/src/com/intellij/util/io/BaseOutputReader.java @@ -123,7 +123,7 @@ public abstract class BaseOutputReader extends BaseDataReader { @Override protected boolean readAvailable() throws IOException { - return readAvailableNonBlocking(); + return mySleepingPolicy == SleepingPolicy.BLOCKING ? readAvailableBlocking() : readAvailableNonBlocking(); } @Override diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/TerminalProcessHandler.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/TerminalProcessHandler.java index 4e22575c7444..383c7cc9d92b 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/TerminalProcessHandler.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/TerminalProcessHandler.java @@ -57,6 +57,11 @@ public class TerminalProcessHandler extends SvnProcessHandler { process.destroy(); } + @Override + protected boolean useNonBlockingRead() { + return false; + } + @Override public void notifyTextAvailable(String text, Key outputType) { terminalOutputCapturer.onTextAvailable(new ProcessEvent(this, text), outputType);