Skip to content

Commit

Permalink
Java: Replacing ByteArrayOutputStream with CircularOutputStream to pr…
Browse files Browse the repository at this point in the history
…event OOM exception. Fixes issue #427
  • Loading branch information
barancev committed Jan 28, 2016
1 parent 976b5e9 commit d4a21ae
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions java/client/src/org/openqa/selenium/os/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ java_library(
srcs = glob(['*.java']),
deps = [
'//java/client/src/org/openqa/selenium:webdriver-api',
'//java/client/src/org/openqa/selenium/io',
'//third_party/java/commons-exec:commons-exec',
'//third_party/java/guava:guava',
'//third_party/java/jna:jna',
Expand Down
6 changes: 3 additions & 3 deletions java/client/src/org/openqa/selenium/os/UnixProcess.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
import org.apache.commons.exec.Executor;
import org.apache.commons.exec.PumpStreamHandler;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.io.CircularOutputStream;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
Expand All @@ -46,7 +46,7 @@
class UnixProcess implements OsProcess {
private static final Logger log = Logger.getLogger(UnixProcess.class.getName());

private final ByteArrayOutputStream inputOut = new ByteArrayOutputStream();
private final CircularOutputStream inputOut = new CircularOutputStream(null);
private volatile String allInput;
private final DefaultExecuteResultHandler handler = new DefaultExecuteResultHandler();
private final Executor executor = new DaemonExecutor();
Expand Down Expand Up @@ -178,7 +178,7 @@ public String getStdOut() {
throw new IllegalStateException(
"Cannot get output before executing command line: " + cl);
}
return new String(inputOut.toByteArray());
return inputOut.toString();
}

public void setInput(String allInput) {
Expand Down
1 change: 1 addition & 0 deletions java/client/src/org/openqa/selenium/os/build.desc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ java_library(name = "os",
srcs = [ "*.java" ],
deps = [
"//java/client/src/org/openqa/selenium:base",
"//java/client/src/org/openqa/selenium/io",
"//third_party/java/commons-exec",
"//third_party/java/guava",
"//third_party/java/jna",
Expand Down

0 comments on commit d4a21ae

Please sign in to comment.