From 4c2b772657734f3e157fbad5ca069efaa013e676 Mon Sep 17 00:00:00 2001 From: Alex Popov Date: Sat, 28 Jun 2025 20:57:06 +0700 Subject: [PATCH 1/4] Add Nullable annotations to Builder class fields in EdgeDriverService --- .../openqa/selenium/edge/EdgeDriverService.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/java/src/org/openqa/selenium/edge/EdgeDriverService.java b/java/src/org/openqa/selenium/edge/EdgeDriverService.java index 4564ec8846d1e..894eb280c120b 100644 --- a/java/src/org/openqa/selenium/edge/EdgeDriverService.java +++ b/java/src/org/openqa/selenium/edge/EdgeDriverService.java @@ -34,6 +34,7 @@ import org.openqa.selenium.chromium.ChromiumDriverLogLevel; import org.openqa.selenium.remote.service.DriverFinder; import org.openqa.selenium.remote.service.DriverService; +import org.jspecify.annotations.Nullable; /** Manages the life and death of the MSEdgeDriver */ public class EdgeDriverService extends DriverService { @@ -139,13 +140,13 @@ public static EdgeDriverService createDefaultService() { @AutoService(DriverService.Builder.class) 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; + @Nullable private Boolean disableBuildCheck; + @Nullable private Boolean readableTimestamp; + @Nullable private Boolean appendLog; + @Nullable private Boolean verbose; + @Nullable private Boolean silent; + @Nullable private String allowedListIps; + @Nullable private ChromiumDriverLogLevel logLevel; @Override public int score(Capabilities capabilities) { From 22827f9d4c59d3176f7a58570f3154e4aaa40eb4 Mon Sep 17 00:00:00 2001 From: Alex Popov Date: Sat, 28 Jun 2025 21:06:05 +0700 Subject: [PATCH 2/4] Add Nullable annotations to parameters in EdgeDriverService and DriverService constructors --- .../openqa/selenium/edge/EdgeDriverService.java | 16 ++++++++-------- .../selenium/remote/service/DriverService.java | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/java/src/org/openqa/selenium/edge/EdgeDriverService.java b/java/src/org/openqa/selenium/edge/EdgeDriverService.java index 894eb280c120b..bc47bce8ab96a 100644 --- a/java/src/org/openqa/selenium/edge/EdgeDriverService.java +++ b/java/src/org/openqa/selenium/edge/EdgeDriverService.java @@ -97,11 +97,11 @@ public class EdgeDriverService extends DriverService { * @throws IOException If an I/O error occurs. */ public EdgeDriverService( - 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, port, timeout, List.copyOf(args), Map.copyOf(environment)); } @@ -197,7 +197,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; @@ -239,7 +239,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; } @@ -250,7 +250,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; } @@ -322,7 +322,7 @@ protected List createArgs() { @Override protected EdgeDriverService 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 EdgeDriverService(exe, port, timeout, args, environment); } catch (IOException e) { diff --git a/java/src/org/openqa/selenium/remote/service/DriverService.java b/java/src/org/openqa/selenium/remote/service/DriverService.java index c62e9d08f998f..371a192fb9bdf 100644 --- a/java/src/org/openqa/selenium/remote/service/DriverService.java +++ b/java/src/org/openqa/selenium/remote/service/DriverService.java @@ -106,11 +106,11 @@ public class DriverService implements Closeable { * @throws IOException If an I/O error occurs. */ protected DriverService( - File executable, + @Nullable File executable, int port, - Duration timeout, - List args, - Map environment) + @Nullable Duration timeout, + @Nullable List args, + @Nullable Map environment) throws IOException { if (executable != null) { this.executable = executable.getCanonicalPath(); From 178bc1d92634341fd3023cb05eaac09106939efd Mon Sep 17 00:00:00 2001 From: Alex Popov Date: Sat, 28 Jun 2025 21:07:56 +0700 Subject: [PATCH 3/4] Refactor EdgeDriverService class documentation and structure --- java/src/org/openqa/selenium/edge/EdgeDriverService.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/java/src/org/openqa/selenium/edge/EdgeDriverService.java b/java/src/org/openqa/selenium/edge/EdgeDriverService.java index bc47bce8ab96a..e9752befce29f 100644 --- a/java/src/org/openqa/selenium/edge/EdgeDriverService.java +++ b/java/src/org/openqa/selenium/edge/EdgeDriverService.java @@ -29,12 +29,12 @@ 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; import org.openqa.selenium.remote.service.DriverFinder; import org.openqa.selenium.remote.service.DriverService; -import org.jspecify.annotations.Nullable; /** Manages the life and death of the MSEdgeDriver */ public class EdgeDriverService extends DriverService { @@ -322,7 +322,11 @@ protected List createArgs() { @Override protected EdgeDriverService createDriverService( - @Nullable File exe, int port, @Nullable Duration timeout, @Nullable List args, @Nullable Map environment) { + @Nullable File exe, + int port, + @Nullable Duration timeout, + @Nullable List args, + @Nullable Map environment) { try { return new EdgeDriverService(exe, port, timeout, args, environment); } catch (IOException e) { From bf081560cb2554703f09be83c65a51a8bdfe1786 Mon Sep 17 00:00:00 2001 From: Alex Popov Date: Sat, 28 Jun 2025 21:23:32 +0700 Subject: [PATCH 4/4] Add dependency on jspecify for EdgeDriver --- java/src/org/openqa/selenium/edge/BUILD.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/java/src/org/openqa/selenium/edge/BUILD.bazel b/java/src/org/openqa/selenium/edge/BUILD.bazel index 7795baf9c1927..b8e8addb9c0cd 100644 --- a/java/src/org/openqa/selenium/edge/BUILD.bazel +++ b/java/src/org/openqa/selenium/edge/BUILD.bazel @@ -21,5 +21,6 @@ java_export( "//java/src/org/openqa/selenium/chromium", "//java/src/org/openqa/selenium/manager", "//java/src/org/openqa/selenium/remote", + "@maven//:org_jspecify_jspecify", ], )