Skip to content

Commit

Permalink
Require Java 11 (#12843)
Browse files Browse the repository at this point in the history
* [java] require Java 11

* [java] remove netty http client and use native java client by default

* [java] updated the list of exports

* [java] use the default http client in tests

* [java] removed --remote-allow-origins=* for the netty client

* [java] removed the asynchttpclient and htmlunit-driver dependencies

---------

Co-authored-by: Jörg Sautter <[email protected]>
  • Loading branch information
titusfortner and joerg1985 authored Oct 6, 2023
1 parent cb5d98b commit 9b35af2
Show file tree
Hide file tree
Showing 26 changed files with 43 additions and 805 deletions.
4 changes: 2 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ build --java_runtime_version=remotejdk_17
build --tool_java_language_version=17
build --tool_java_runtime_version=remotejdk_17

# We target java 8 by default
# We target java 11 by default

build --javacopt="--release 8"
build --javacopt="--release 11"

# Require java dependencies to be used and first-order

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ jobs:
browser: ${{ matrix.browser }}
cache-key: rb-remote-${{ matrix.browser }}-test
os: ${{ matrix.os }}
java-version: 11
run: >
bazel test
--define browser=${{ matrix.browser }}
Expand Down
9 changes: 0 additions & 9 deletions java/maven_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,6 @@ def selenium_java_deps():
"org.apache.commons:commons-exec:1.3",
"org.apache.logging.log4j:log4j-core:2.20.0",
"org.assertj:assertj-core:3.24.2",
maven.artifact(
group = "org.asynchttpclient",
artifact = "async-http-client",
version = "2.12.3",
exclusions = [
"io.netty:netty-transport-native-epoll",
"io.netty:netty-transport-native-kqueue",
],
),
"org.bouncycastle:bcpkix-jdk15on:1.70",
"org.eclipse.mylyn.github:org.eclipse.egit.github.core:2.1.5",
"org.hamcrest:hamcrest:2.2",
Expand Down
112 changes: 2 additions & 110 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": 1617623649,
"__RESOLVED_ARTIFACTS_HASH": 2144519154,
"__INPUT_ARTIFACTS_HASH": -486878249,
"__RESOLVED_ARTIFACTS_HASH": 1235473565,
"artifacts": {
"com.beust:jcommander": {
"shasums": {
Expand Down Expand Up @@ -178,20 +178,6 @@
},
"version": "3.2.0"
},
"com.sun.activation:jakarta.activation": {
"shasums": {
"jar": "02156773e4ae9d048d14a56ad35d644bee9f1052a791d072df3ded3c656e6e1a",
"sources": "f8f52ce9df5d5d29c1778183d48214624caa36be202a7eff2cef5a0519f2aa53"
},
"version": "1.2.2"
},
"com.typesafe.netty:netty-reactive-streams": {
"shasums": {
"jar": "eafc52d500b49e891db095ee7baac0420aea8a97015ab7671ba1f1ccabf799d2",
"sources": "76df17cc7c4fac9c470e557b5cca224df51ba878ec9fd3fd8f0f89878cbf98ab"
},
"version": "2.0.4"
},
"commons-codec:commons-codec": {
"shasums": {
"jar": "b3e9f6d63a790109bf0d056611fbed1cf69055826defeb9894a71369d246ed63",
Expand Down Expand Up @@ -629,20 +615,6 @@
},
"version": "3.24.2"
},
"org.asynchttpclient:async-http-client": {
"shasums": {
"jar": "107a4ace7a3586f8e8a027c6d7e9933c9ae56eeb1a6df347eed2e7b552e4e5ed",
"sources": "fd7d5e61cb6e5adbb06c14b72c10c88e18ebfaf22d401a521eae14123b537900"
},
"version": "2.12.3"
},
"org.asynchttpclient:async-http-client-netty-utils": {
"shasums": {
"jar": "e0bb76bbca0c85c68cab25dbed7989b00db5da8627cf69258f398d7d89bc9067",
"sources": "0b66a2867a3e4ea1e101e64d961d677bc6fbbbefa462b8fac461ef9101bec435"
},
"version": "2.12.3"
},
"org.bouncycastle:bcpkix-jdk15on": {
"shasums": {
"jar": "e5b9cb821df57f70b0593358e89c0e8d7266515da9d088af6c646f63d433c07c",
Expand Down Expand Up @@ -966,10 +938,6 @@
"com.graphql-java:java-dataloader": [
"org.slf4j:slf4j-api"
],
"com.typesafe.netty:netty-reactive-streams": [
"io.netty:netty-handler",
"org.reactivestreams:reactive-streams"
],
"io.grpc:grpc-context": [
"io.grpc:grpc-api"
],
Expand Down Expand Up @@ -1190,22 +1158,6 @@
"org.assertj:assertj-core": [
"net.bytebuddy:byte-buddy"
],
"org.asynchttpclient:async-http-client": [
"com.sun.activation:jakarta.activation",
"com.typesafe.netty:netty-reactive-streams",
"io.netty:netty-codec-http",
"io.netty:netty-codec-socks",
"io.netty:netty-handler",
"io.netty:netty-handler-proxy",
"org.asynchttpclient:async-http-client-netty-utils",
"org.reactivestreams:reactive-streams",
"org.slf4j:slf4j-api"
],
"org.asynchttpclient:async-http-client-netty-utils": [
"com.sun.activation:jakarta.activation",
"io.netty:netty-buffer",
"org.slf4j:slf4j-api"
],
"org.bouncycastle:bcpkix-jdk15on": [
"org.bouncycastle:bcprov-jdk15on",
"org.bouncycastle:bcutil-jdk15on"
Expand Down Expand Up @@ -1613,14 +1565,6 @@
"org.dataloader.stats",
"org.dataloader.stats.context"
],
"com.sun.activation:jakarta.activation": [
"com.sun.activation.registries",
"com.sun.activation.viewers",
"javax.activation"
],
"com.typesafe.netty:netty-reactive-streams": [
"com.typesafe.netty"
],
"commons-codec:commons-codec": [
"org.apache.commons.codec",
"org.apache.commons.codec.binary",
Expand Down Expand Up @@ -2384,42 +2328,6 @@
"org.assertj.core.util.introspection",
"org.assertj.core.util.xml"
],
"org.asynchttpclient:async-http-client": [
"org.asynchttpclient",
"org.asynchttpclient.channel",
"org.asynchttpclient.config",
"org.asynchttpclient.cookie",
"org.asynchttpclient.exception",
"org.asynchttpclient.filter",
"org.asynchttpclient.handler",
"org.asynchttpclient.handler.resumable",
"org.asynchttpclient.netty",
"org.asynchttpclient.netty.channel",
"org.asynchttpclient.netty.future",
"org.asynchttpclient.netty.handler",
"org.asynchttpclient.netty.handler.intercept",
"org.asynchttpclient.netty.request",
"org.asynchttpclient.netty.request.body",
"org.asynchttpclient.netty.ssl",
"org.asynchttpclient.netty.timeout",
"org.asynchttpclient.netty.ws",
"org.asynchttpclient.ntlm",
"org.asynchttpclient.oauth",
"org.asynchttpclient.proxy",
"org.asynchttpclient.request.body",
"org.asynchttpclient.request.body.generator",
"org.asynchttpclient.request.body.multipart",
"org.asynchttpclient.request.body.multipart.part",
"org.asynchttpclient.resolver",
"org.asynchttpclient.spnego",
"org.asynchttpclient.uri",
"org.asynchttpclient.util",
"org.asynchttpclient.webdav",
"org.asynchttpclient.ws"
],
"org.asynchttpclient:async-http-client-netty-utils": [
"org.asynchttpclient.netty.util"
],
"org.bouncycastle:bcpkix-jdk15on": [
"org.bouncycastle.cert",
"org.bouncycastle.cert.bc",
Expand Down Expand Up @@ -3187,10 +3095,6 @@
"com.graphql-java:graphql-java:jar:sources",
"com.graphql-java:java-dataloader",
"com.graphql-java:java-dataloader:jar:sources",
"com.sun.activation:jakarta.activation",
"com.sun.activation:jakarta.activation:jar:sources",
"com.typesafe.netty:netty-reactive-streams",
"com.typesafe.netty:netty-reactive-streams:jar:sources",
"commons-codec:commons-codec",
"commons-codec:commons-codec:jar:sources",
"commons-io:commons-io",
Expand Down Expand Up @@ -3318,10 +3222,6 @@
"org.apiguardian:apiguardian-api:jar:sources",
"org.assertj:assertj-core",
"org.assertj:assertj-core:jar:sources",
"org.asynchttpclient:async-http-client",
"org.asynchttpclient:async-http-client-netty-utils",
"org.asynchttpclient:async-http-client-netty-utils:jar:sources",
"org.asynchttpclient:async-http-client:jar:sources",
"org.bouncycastle:bcpkix-jdk15on",
"org.bouncycastle:bcpkix-jdk15on:jar:sources",
"org.bouncycastle:bcprov-jdk15on",
Expand Down Expand Up @@ -3448,10 +3348,6 @@
"com.graphql-java:graphql-java:jar:sources",
"com.graphql-java:java-dataloader",
"com.graphql-java:java-dataloader:jar:sources",
"com.sun.activation:jakarta.activation",
"com.sun.activation:jakarta.activation:jar:sources",
"com.typesafe.netty:netty-reactive-streams",
"com.typesafe.netty:netty-reactive-streams:jar:sources",
"commons-codec:commons-codec",
"commons-codec:commons-codec:jar:sources",
"commons-io:commons-io",
Expand Down Expand Up @@ -3579,10 +3475,6 @@
"org.apiguardian:apiguardian-api:jar:sources",
"org.assertj:assertj-core",
"org.assertj:assertj-core:jar:sources",
"org.asynchttpclient:async-http-client",
"org.asynchttpclient:async-http-client-netty-utils",
"org.asynchttpclient:async-http-client-netty-utils:jar:sources",
"org.asynchttpclient:async-http-client:jar:sources",
"org.bouncycastle:bcpkix-jdk15on",
"org.bouncycastle:bcpkix-jdk15on:jar:sources",
"org.bouncycastle:bcprov-jdk15on",
Expand Down
20 changes: 20 additions & 0 deletions java/spotbugs-excludes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,26 @@
<Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD"/>
</Match>

<Match>
<Class name="org.openqa.selenium.remote.http.jdk.JdkHttpClient"/>
<Bug pattern="SF_SWITCH_FALLTHROUGH"/>
</Match>

<Match>
<Class name="org.openqa.selenium.safari.SafariDriverService"/>
<Bug pattern="DMI_HARDCODED_ABSOLUTE_FILENAME"/>
</Match>

<Match>
<Class name="org.openqa.selenium.support.locators.RelativeLocator$RelativeBy" />
<Bug pattern="UPM_UNCALLED_PRIVATE_METHOD" />
</Match>

<Match>
<Class name="org.openqa.selenium.json.JsonOutputTest$1PrivatelyMappable" />
<Bug pattern="UPM_UNCALLED_PRIVATE_METHOD" />
</Match>

<Match>
<Class name="org.openqa.selenium.testing.Pages"/>
<Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/>
Expand All @@ -165,6 +180,11 @@
<Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD"/>
</Match>

<Match>
<Class name="org.openqa.selenium.json.JsonOutputTest"/>
<Bug pattern="UPM_UNCALLED_PRIVATE_METHOD"/>
</Match>

<Match>
<Class name="org.openqa.selenium.testing.JupiterTestBase"/>
<Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/>
Expand Down
13 changes: 0 additions & 13 deletions java/src/org/openqa/selenium/chrome/ChromeDriverInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import static org.openqa.selenium.remote.Browser.CHROME;

import com.google.auto.service.AutoService;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import java.util.Optional;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.ImmutableCapabilities;
Expand All @@ -43,17 +41,6 @@ public String getDisplayName() {

@Override
public Capabilities getCanonicalCapabilities() {
if (!"jdk-http-client".equalsIgnoreCase(System.getProperty("webdriver.http.factory", ""))) {
// Allowing any origin "*" through remote-allow-origins might sound risky but an attacker
// would need to know the port used to start DevTools to establish a connection. Given
// these sessions are relatively short-lived, the risk is reduced. Only set when the Java
// 11 client is not used.
return new ImmutableCapabilities(
CapabilityType.BROWSER_NAME,
CHROME.browserName(),
ChromeOptions.CAPABILITY,
ImmutableMap.of("args", ImmutableList.of("--remote-allow-origins=*")));
}
return new ImmutableCapabilities(CapabilityType.BROWSER_NAME, CHROME.browserName());
}

Expand Down
7 changes: 0 additions & 7 deletions java/src/org/openqa/selenium/chromium/ChromiumOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,6 @@ public class ChromiumOptions<T extends ChromiumOptions<?>>
public ChromiumOptions(String capabilityType, String browserType, String capability) {
this.capabilityName = capability;
setCapability(capabilityType, browserType);
if (!"jdk-http-client".equalsIgnoreCase(System.getProperty("webdriver.http.factory", ""))) {
// Allowing any origin "*" might sound risky but an attacker would need to know
// the port used to start DevTools to establish a connection. Given these sessions
// are relatively short-lived, the risk is reduced. Only set when the Java 11 client
// is not used.
addArguments("--remote-allow-origins=*");
}
}

/**
Expand Down
13 changes: 0 additions & 13 deletions java/src/org/openqa/selenium/edge/EdgeDriverInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import static org.openqa.selenium.remote.Browser.EDGE;

import com.google.auto.service.AutoService;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import java.util.Optional;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.ImmutableCapabilities;
Expand All @@ -43,17 +41,6 @@ public String getDisplayName() {

@Override
public Capabilities getCanonicalCapabilities() {
if (!"jdk-http-client".equalsIgnoreCase(System.getProperty("webdriver.http.factory", ""))) {
// Allowing any origin "*" through remote-allow-origins might sound risky but an attacker
// would need to know the port used to start DevTools to establish a connection. Given
// these sessions are relatively short-lived, the risk is reduced. Only set when the Java
// 11 client is not used.
return new ImmutableCapabilities(
CapabilityType.BROWSER_NAME,
EDGE.browserName(),
EdgeOptions.CAPABILITY,
ImmutableMap.of("args", ImmutableList.of("--remote-allow-origins=*")));
}
return new ImmutableCapabilities(CapabilityType.BROWSER_NAME, EDGE.browserName());
}

Expand Down
1 change: 0 additions & 1 deletion java/src/org/openqa/selenium/grid/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ maven_bom(
"//java/src/org/openqa/selenium/json:json",
"//java/src/org/openqa/selenium/lift:lift",
"//java/src/org/openqa/selenium/manager:manager",
"//java/src/org/openqa/selenium/remote/http/jdk:jdk",
"//java/src/org/openqa/selenium/remote/http:http",
"//java/src/org/openqa/selenium/remote:remote",
"//java/src/org/openqa/selenium/safari:safari",
Expand Down
2 changes: 1 addition & 1 deletion java/src/org/openqa/selenium/remote/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ java_library(
"//java/src/org/openqa/selenium/json",
"//java/src/org/openqa/selenium/manager",
"//java/src/org/openqa/selenium/os",
"//java/src/org/openqa/selenium/remote/http/netty",
"//java/src/org/openqa/selenium/remote/http/jdk",
"//java/src/org/openqa/selenium/remote/tracing",
"//java/src/org/openqa/selenium/remote/tracing/opentelemetry",
"//java/src/org/openqa/selenium/support/decorators",
Expand Down
2 changes: 1 addition & 1 deletion java/src/org/openqa/selenium/remote/http/HttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static Factory create(String name) {
* <p>{@see create}
*/
static Factory createDefault() {
return create(System.getProperty("webdriver.http.factory", "netty"));
return create(System.getProperty("webdriver.http.factory", "jdk-http-client"));
}

/**
Expand Down
14 changes: 4 additions & 10 deletions java/src/org/openqa/selenium/remote/http/jdk/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
load("//java:defs.bzl", "java_export")
load("//java:version.bzl", "SE_VERSION")
load("//java:defs.bzl", "java_library")

java_export(
java_library(
name = "jdk",
srcs = glob(["*.java"]),
javacopts = [
"--release",
"11", # Deliberately targeting Java 11 for widest possible support
],
maven_coordinates = "org.seleniumhq.selenium:selenium-http-jdk-client:%s" % SE_VERSION,
pom_template = "//java/src/org/openqa/selenium:template-pom",
visibility = [
"//visibility:public",
"//java/src/org/openqa/selenium/remote:__pkg__",
"//java/test/org/openqa/selenium/remote/http:__subpackages__",
],
deps = [
"//java:auto-service",
Expand Down
1 change: 0 additions & 1 deletion java/src/org/openqa/selenium/remote/http/netty/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ java_library(
"//java/src/org/openqa/selenium/remote/http",
artifact("com.google.guava:guava"),
# artifact("com.typesafe.netty:netty-reactive-streams"),
artifact("org.asynchttpclient:async-http-client"),
artifact("io.netty:netty-buffer"),
artifact("io.netty:netty-codec-http"),
artifact("io.netty:netty-transport"),
Expand Down
Loading

0 comments on commit 9b35af2

Please sign in to comment.