Skip to content

Commit 13cab26

Browse files
committed
[java] replaced commons-exec with the java process builder
1 parent 0f8e018 commit 13cab26

File tree

12 files changed

+331
-657
lines changed

12 files changed

+331
-657
lines changed

java/maven_deps.bzl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ def selenium_java_deps():
7272
"it.ozimov:embedded-redis:0.7.3",
7373
"net.bytebuddy:byte-buddy:1.14.5",
7474
"net.sourceforge.htmlunit:htmlunit-core-js:2.70.0",
75-
"org.apache.commons:commons-exec:1.3",
7675
"org.apache.logging.log4j:log4j-core:2.20.0",
7776
"org.assertj:assertj-core:3.24.2",
7877
"org.bouncycastle:bcpkix-jdk15on:1.70",

java/maven_install.json

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL",
3-
"__INPUT_ARTIFACTS_HASH": -486878249,
4-
"__RESOLVED_ARTIFACTS_HASH": 1235473565,
3+
"__INPUT_ARTIFACTS_HASH": -521743349,
4+
"__RESOLVED_ARTIFACTS_HASH": -882481443,
55
"artifacts": {
66
"com.beust:jcommander": {
77
"shasums": {
@@ -545,13 +545,6 @@
545545
},
546546
"version": "6.5.0"
547547
},
548-
"org.apache.commons:commons-exec": {
549-
"shasums": {
550-
"jar": "cb49812dc1bfb0ea4f20f398bcae1a88c6406e213e67f7524fb10d4f8ad9347b",
551-
"sources": "c121d8e70010092bafc56f358e7259ac484653db595aafea1e67a040f51aea66"
552-
},
553-
"version": "1.3"
554-
},
555548
"org.apache.commons:commons-lang3": {
556549
"shasums": {
557550
"jar": "d919d904486c037f8d193412da0c92e22a9fa24230b9d67a57855c5c31c7e94e",
@@ -2119,12 +2112,6 @@
21192112
"org.apache.bcel.verifier.statics",
21202113
"org.apache.bcel.verifier.structurals"
21212114
],
2122-
"org.apache.commons:commons-exec": [
2123-
"org.apache.commons.exec",
2124-
"org.apache.commons.exec.environment",
2125-
"org.apache.commons.exec.launcher",
2126-
"org.apache.commons.exec.util"
2127-
],
21282115
"org.apache.commons:commons-lang3": [
21292116
"org.apache.commons.lang3",
21302117
"org.apache.commons.lang3.arch",
@@ -3202,8 +3189,6 @@
32023189
"net.sourceforge.htmlunit:htmlunit-core-js:jar:sources",
32033190
"org.apache.bcel:bcel",
32043191
"org.apache.bcel:bcel:jar:sources",
3205-
"org.apache.commons:commons-exec",
3206-
"org.apache.commons:commons-exec:jar:sources",
32073192
"org.apache.commons:commons-lang3",
32083193
"org.apache.commons:commons-lang3:jar:sources",
32093194
"org.apache.commons:commons-text",
@@ -3455,8 +3440,6 @@
34553440
"net.sourceforge.htmlunit:htmlunit-core-js:jar:sources",
34563441
"org.apache.bcel:bcel",
34573442
"org.apache.bcel:bcel:jar:sources",
3458-
"org.apache.commons:commons-exec",
3459-
"org.apache.commons:commons-exec:jar:sources",
34603443
"org.apache.commons:commons-lang3",
34613444
"org.apache.commons:commons-lang3:jar:sources",
34623445
"org.apache.commons:commons-text",

java/src/org/openqa/selenium/manager/SeleniumManager.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.nio.file.Paths;
2929
import java.nio.file.SimpleFileVisitor;
3030
import java.nio.file.attribute.BasicFileAttributes;
31+
import java.time.Duration;
3132
import java.util.ArrayList;
3233
import java.util.Arrays;
3334
import java.util.List;
@@ -43,7 +44,7 @@
4344
import org.openqa.selenium.json.Json;
4445
import org.openqa.selenium.json.JsonException;
4546
import org.openqa.selenium.manager.SeleniumManagerOutput.Result;
46-
import org.openqa.selenium.os.CommandLine;
47+
import org.openqa.selenium.os.OsProcess;
4748

4849
/**
4950
* This implementation is still in beta, and may change.
@@ -112,15 +113,14 @@ private static Result runCommand(Path binary, List<String> arguments) {
112113
String output;
113114
int code;
114115
try {
115-
CommandLine command =
116-
new CommandLine(binary.toAbsolutePath().toString(), arguments.toArray(new String[0]));
117-
command.executeAsync();
118-
command.waitFor();
119-
if (command.isRunning()) {
120-
LOG.warning("Selenium Manager did not exit");
116+
OsProcess process =
117+
OsProcess.builder().command(binary.toAbsolutePath().toString(), arguments).start();
118+
if (!process.waitFor(Duration.ofHours(1))) {
119+
LOG.warning("Selenium Manager did not exit, shutting it down");
120+
process.shutdown();
121121
}
122-
code = command.getExitCode();
123-
output = command.getStdOut();
122+
code = process.exitValue();
123+
output = process.getOutput();
124124
} catch (Exception e) {
125125
throw new WebDriverException("Failed to run command: " + arguments, e);
126126
}

java/src/org/openqa/selenium/os/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ java_export(
1111
deps = [
1212
"//java/src/org/openqa/selenium:core",
1313
"//java/src/org/openqa/selenium/io",
14-
artifact("org.apache.commons:commons-exec"),
1514
artifact("com.google.guava:guava"),
1615
],
1716
)

java/src/org/openqa/selenium/os/CommandLine.java

Lines changed: 0 additions & 174 deletions
This file was deleted.

0 commit comments

Comments
 (0)