Skip to content

Commit

Permalink
[java] replaced commons-exec with the java process builder
Browse files Browse the repository at this point in the history
  • Loading branch information
joerg1985 committed Oct 7, 2023
1 parent 0f8e018 commit 13cab26
Show file tree
Hide file tree
Showing 12 changed files with 331 additions and 657 deletions.
1 change: 0 additions & 1 deletion java/maven_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ def selenium_java_deps():
"it.ozimov:embedded-redis:0.7.3",
"net.bytebuddy:byte-buddy:1.14.5",
"net.sourceforge.htmlunit:htmlunit-core-js:2.70.0",
"org.apache.commons:commons-exec:1.3",
"org.apache.logging.log4j:log4j-core:2.20.0",
"org.assertj:assertj-core:3.24.2",
"org.bouncycastle:bcpkix-jdk15on:1.70",
Expand Down
21 changes: 2 additions & 19 deletions java/maven_install.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL",
"__INPUT_ARTIFACTS_HASH": -486878249,
"__RESOLVED_ARTIFACTS_HASH": 1235473565,
"__INPUT_ARTIFACTS_HASH": -521743349,
"__RESOLVED_ARTIFACTS_HASH": -882481443,
"artifacts": {
"com.beust:jcommander": {
"shasums": {
Expand Down Expand Up @@ -545,13 +545,6 @@
},
"version": "6.5.0"
},
"org.apache.commons:commons-exec": {
"shasums": {
"jar": "cb49812dc1bfb0ea4f20f398bcae1a88c6406e213e67f7524fb10d4f8ad9347b",
"sources": "c121d8e70010092bafc56f358e7259ac484653db595aafea1e67a040f51aea66"
},
"version": "1.3"
},
"org.apache.commons:commons-lang3": {
"shasums": {
"jar": "d919d904486c037f8d193412da0c92e22a9fa24230b9d67a57855c5c31c7e94e",
Expand Down Expand Up @@ -2119,12 +2112,6 @@
"org.apache.bcel.verifier.statics",
"org.apache.bcel.verifier.structurals"
],
"org.apache.commons:commons-exec": [
"org.apache.commons.exec",
"org.apache.commons.exec.environment",
"org.apache.commons.exec.launcher",
"org.apache.commons.exec.util"
],
"org.apache.commons:commons-lang3": [
"org.apache.commons.lang3",
"org.apache.commons.lang3.arch",
Expand Down Expand Up @@ -3202,8 +3189,6 @@
"net.sourceforge.htmlunit:htmlunit-core-js:jar:sources",
"org.apache.bcel:bcel",
"org.apache.bcel:bcel:jar:sources",
"org.apache.commons:commons-exec",
"org.apache.commons:commons-exec:jar:sources",
"org.apache.commons:commons-lang3",
"org.apache.commons:commons-lang3:jar:sources",
"org.apache.commons:commons-text",
Expand Down Expand Up @@ -3455,8 +3440,6 @@
"net.sourceforge.htmlunit:htmlunit-core-js:jar:sources",
"org.apache.bcel:bcel",
"org.apache.bcel:bcel:jar:sources",
"org.apache.commons:commons-exec",
"org.apache.commons:commons-exec:jar:sources",
"org.apache.commons:commons-lang3",
"org.apache.commons:commons-lang3:jar:sources",
"org.apache.commons:commons-text",
Expand Down
18 changes: 9 additions & 9 deletions java/src/org/openqa/selenium/manager/SeleniumManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand All @@ -43,7 +44,7 @@
import org.openqa.selenium.json.Json;
import org.openqa.selenium.json.JsonException;
import org.openqa.selenium.manager.SeleniumManagerOutput.Result;
import org.openqa.selenium.os.CommandLine;
import org.openqa.selenium.os.OsProcess;

/**
* This implementation is still in beta, and may change.
Expand Down Expand Up @@ -112,15 +113,14 @@ private static Result runCommand(Path binary, List<String> arguments) {
String output;
int code;
try {
CommandLine command =
new CommandLine(binary.toAbsolutePath().toString(), arguments.toArray(new String[0]));
command.executeAsync();
command.waitFor();
if (command.isRunning()) {
LOG.warning("Selenium Manager did not exit");
OsProcess process =
OsProcess.builder().command(binary.toAbsolutePath().toString(), arguments).start();
if (!process.waitFor(Duration.ofHours(1))) {
LOG.warning("Selenium Manager did not exit, shutting it down");
process.shutdown();
}
code = command.getExitCode();
output = command.getStdOut();
code = process.exitValue();
output = process.getOutput();
} catch (Exception e) {
throw new WebDriverException("Failed to run command: " + arguments, e);
}
Expand Down
1 change: 0 additions & 1 deletion java/src/org/openqa/selenium/os/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ java_export(
deps = [
"//java/src/org/openqa/selenium:core",
"//java/src/org/openqa/selenium/io",
artifact("org.apache.commons:commons-exec"),
artifact("com.google.guava:guava"),
],
)
174 changes: 0 additions & 174 deletions java/src/org/openqa/selenium/os/CommandLine.java

This file was deleted.

Loading

0 comments on commit 13cab26

Please sign in to comment.