Skip to content

Commit d4a21ae

Browse files
committed
Java: Replacing ByteArrayOutputStream with CircularOutputStream to prevent OOM exception. Fixes issue #427
1 parent 976b5e9 commit d4a21ae

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

java/client/src/org/openqa/selenium/os/BUCK

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ java_library(
33
srcs = glob(['*.java']),
44
deps = [
55
'//java/client/src/org/openqa/selenium:webdriver-api',
6+
'//java/client/src/org/openqa/selenium/io',
67
'//third_party/java/commons-exec:commons-exec',
78
'//third_party/java/guava:guava',
89
'//third_party/java/jna:jna',

java/client/src/org/openqa/selenium/os/UnixProcess.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
import org.apache.commons.exec.Executor;
3232
import org.apache.commons.exec.PumpStreamHandler;
3333
import org.openqa.selenium.WebDriverException;
34+
import org.openqa.selenium.io.CircularOutputStream;
3435

3536
import java.io.ByteArrayInputStream;
36-
import java.io.ByteArrayOutputStream;
3737
import java.io.File;
3838
import java.io.IOException;
3939
import java.io.OutputStream;
@@ -46,7 +46,7 @@
4646
class UnixProcess implements OsProcess {
4747
private static final Logger log = Logger.getLogger(UnixProcess.class.getName());
4848

49-
private final ByteArrayOutputStream inputOut = new ByteArrayOutputStream();
49+
private final CircularOutputStream inputOut = new CircularOutputStream(null);
5050
private volatile String allInput;
5151
private final DefaultExecuteResultHandler handler = new DefaultExecuteResultHandler();
5252
private final Executor executor = new DaemonExecutor();
@@ -178,7 +178,7 @@ public String getStdOut() {
178178
throw new IllegalStateException(
179179
"Cannot get output before executing command line: " + cl);
180180
}
181-
return new String(inputOut.toByteArray());
181+
return inputOut.toString();
182182
}
183183

184184
public void setInput(String allInput) {

java/client/src/org/openqa/selenium/os/build.desc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ java_library(name = "os",
33
srcs = [ "*.java" ],
44
deps = [
55
"//java/client/src/org/openqa/selenium:base",
6+
"//java/client/src/org/openqa/selenium/io",
67
"//third_party/java/commons-exec",
78
"//third_party/java/guava",
89
"//third_party/java/jna",

0 commit comments

Comments
 (0)