diff --git a/java/src/org/openqa/selenium/chrome/BUILD.bazel b/java/src/org/openqa/selenium/chrome/BUILD.bazel index 7c536fc96351d..27b34f123f956 100644 --- a/java/src/org/openqa/selenium/chrome/BUILD.bazel +++ b/java/src/org/openqa/selenium/chrome/BUILD.bazel @@ -20,5 +20,6 @@ java_export( "//java/src/org/openqa/selenium/json", "//java/src/org/openqa/selenium/manager", "//java/src/org/openqa/selenium/remote", + "@maven//:org_jspecify_jspecify", ], ) diff --git a/java/src/org/openqa/selenium/chrome/ChromeDriverService.java b/java/src/org/openqa/selenium/chrome/ChromeDriverService.java index 700faaf90652c..5ab2d37844b73 100644 --- a/java/src/org/openqa/selenium/chrome/ChromeDriverService.java +++ b/java/src/org/openqa/selenium/chrome/ChromeDriverService.java @@ -31,6 +31,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; +import org.jspecify.annotations.Nullable; import org.openqa.selenium.Capabilities; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.chromium.ChromiumDriverLogLevel; @@ -102,11 +103,11 @@ public class ChromeDriverService extends DriverService { * @throws IOException If an I/O error occurs. */ public ChromeDriverService( - File executable, + @Nullable File executable, int port, - Duration timeout, - List args, - Map environment) + @Nullable Duration timeout, + @Nullable List args, + @Nullable Map environment) throws IOException { super( executable, @@ -151,13 +152,13 @@ public static ChromeDriverService createDefaultService() { public static class Builder extends DriverService.Builder { - private Boolean disableBuildCheck; - private Boolean readableTimestamp; - private Boolean appendLog; - private Boolean verbose; - private Boolean silent; - private String allowedListIps; - private ChromiumDriverLogLevel logLevel; + private @Nullable Boolean disableBuildCheck; + private @Nullable Boolean readableTimestamp; + private @Nullable Boolean appendLog; + private @Nullable Boolean verbose; + private @Nullable Boolean silent; + private @Nullable String allowedListIps; + private @Nullable ChromiumDriverLogLevel logLevel; @Override public int score(Capabilities capabilities) { @@ -202,7 +203,7 @@ public Builder withBuildCheckDisabled(boolean noBuildCheck) { * @param logLevel {@link ChromiumDriverLogLevel} for desired log level output. * @return A self reference. */ - public Builder withLogLevel(ChromiumDriverLogLevel logLevel) { + public Builder withLogLevel(@Nullable ChromiumDriverLogLevel logLevel) { this.logLevel = logLevel; this.silent = false; this.verbose = false; @@ -244,7 +245,7 @@ public Builder withVerbose(boolean verbose) { * @param allowedListIps Comma-separated list of remote IPv4 addresses. * @return A self reference. */ - public Builder withAllowedListIps(String allowedListIps) { + public Builder withAllowedListIps(@Nullable String allowedListIps) { this.allowedListIps = allowedListIps; return this; } @@ -255,7 +256,7 @@ public Builder withAllowedListIps(String allowedListIps) { * @param readableTimestamp Whether the timestamp of the log is readable. * @return A self reference. */ - public Builder withReadableTimestamp(Boolean readableTimestamp) { + public Builder withReadableTimestamp(@Nullable Boolean readableTimestamp) { this.readableTimestamp = readableTimestamp; return this; } @@ -321,7 +322,11 @@ protected List createArgs() { @Override protected ChromeDriverService createDriverService( - File exe, int port, Duration timeout, List args, Map environment) { + @Nullable File exe, + int port, + @Nullable Duration timeout, + @Nullable List args, + @Nullable Map environment) { try { return new ChromeDriverService(exe, port, timeout, args, environment); } catch (IOException e) {