Skip to content

Commit efe5a4f

Browse files
authored
[java] Add JSpecify annotations to ChromiumDriver (Issue #14291) (#16628)
* [java] Add JSpecify annotations to ChromiumDriver * docs(chromium): add javadoc explaining nullability for casting and cdp fields
1 parent 9667310 commit efe5a4f

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("//java:defs.bzl", "java_export")
1+
load("//java:defs.bzl", "artifact", "java_export")
22
load("//java:version.bzl", "SE_VERSION")
33

44
java_export(
@@ -19,5 +19,6 @@ java_export(
1919
"//java:auto-service",
2020
"//java/src/org/openqa/selenium/json",
2121
"//java/src/org/openqa/selenium/remote",
22+
artifact("org.jspecify:jspecify"),
2223
],
2324
)

java/src/org/openqa/selenium/chromium/ChromiumDriver.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
import java.util.function.Supplier;
3333
import java.util.logging.Level;
3434
import java.util.logging.Logger;
35+
import org.jspecify.annotations.NullMarked;
36+
import org.jspecify.annotations.Nullable;
3537
import org.openqa.selenium.BuildInfo;
3638
import org.openqa.selenium.Capabilities;
3739
import org.openqa.selenium.Credentials;
@@ -67,6 +69,7 @@
6769
* A {@link WebDriver} implementation that controls a Chromium browser running on the local machine.
6870
* It is used as the base class for Chromium-based browser drivers (Chrome, Edge).
6971
*/
72+
@NullMarked
7073
public class ChromiumDriver extends RemoteWebDriver
7174
implements HasAuthentication,
7275
HasBiDi,
@@ -90,8 +93,15 @@ public class ChromiumDriver extends RemoteWebDriver
9093
private final Optional<DevTools> devTools;
9194
private final Optional<URI> biDiUri;
9295
private final Optional<BiDi> biDi;
93-
protected HasCasting casting;
94-
protected HasCdp cdp;
96+
97+
/**
98+
* May be null when the driver does not support casting; initialized during setup if available.
99+
*/
100+
protected @Nullable HasCasting casting;
101+
102+
/** May be null when CDP is unavailable for the current browser/session. */
103+
protected @Nullable HasCdp cdp;
104+
95105
private final Map<Integer, ScriptKey> scriptKeys = new HashMap<>();
96106

97107
protected ChromiumDriver(

0 commit comments

Comments
 (0)