Skip to content

Commit 5d1ee30

Browse files
iampopovichdiemol
andauthored
[java] Feat 14291/jspecify nullable annotation chrome driver såervice (#15998)
* Add JSpecify nullable annotations to ChromeDriverService parameters * applied format.sh --------- Co-authored-by: Diego Molina <[email protected]>
1 parent 15b84f3 commit 5d1ee30

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ java_export(
2020
"//java/src/org/openqa/selenium/json",
2121
"//java/src/org/openqa/selenium/manager",
2222
"//java/src/org/openqa/selenium/remote",
23+
"@maven//:org_jspecify_jspecify",
2324
],
2425
)

java/src/org/openqa/selenium/chrome/ChromeDriverService.java

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.util.List;
3232
import java.util.Locale;
3333
import java.util.Map;
34+
import org.jspecify.annotations.Nullable;
3435
import org.openqa.selenium.Capabilities;
3536
import org.openqa.selenium.WebDriverException;
3637
import org.openqa.selenium.chromium.ChromiumDriverLogLevel;
@@ -102,11 +103,11 @@ public class ChromeDriverService extends DriverService {
102103
* @throws IOException If an I/O error occurs.
103104
*/
104105
public ChromeDriverService(
105-
File executable,
106+
@Nullable File executable,
106107
int port,
107-
Duration timeout,
108-
List<String> args,
109-
Map<String, String> environment)
108+
@Nullable Duration timeout,
109+
@Nullable List<String> args,
110+
@Nullable Map<String, String> environment)
110111
throws IOException {
111112
super(
112113
executable,
@@ -151,13 +152,13 @@ public static ChromeDriverService createDefaultService() {
151152
public static class Builder
152153
extends DriverService.Builder<ChromeDriverService, ChromeDriverService.Builder> {
153154

154-
private Boolean disableBuildCheck;
155-
private Boolean readableTimestamp;
156-
private Boolean appendLog;
157-
private Boolean verbose;
158-
private Boolean silent;
159-
private String allowedListIps;
160-
private ChromiumDriverLogLevel logLevel;
155+
private @Nullable Boolean disableBuildCheck;
156+
private @Nullable Boolean readableTimestamp;
157+
private @Nullable Boolean appendLog;
158+
private @Nullable Boolean verbose;
159+
private @Nullable Boolean silent;
160+
private @Nullable String allowedListIps;
161+
private @Nullable ChromiumDriverLogLevel logLevel;
161162

162163
@Override
163164
public int score(Capabilities capabilities) {
@@ -202,7 +203,7 @@ public Builder withBuildCheckDisabled(boolean noBuildCheck) {
202203
* @param logLevel {@link ChromiumDriverLogLevel} for desired log level output.
203204
* @return A self reference.
204205
*/
205-
public Builder withLogLevel(ChromiumDriverLogLevel logLevel) {
206+
public Builder withLogLevel(@Nullable ChromiumDriverLogLevel logLevel) {
206207
this.logLevel = logLevel;
207208
this.silent = false;
208209
this.verbose = false;
@@ -244,7 +245,7 @@ public Builder withVerbose(boolean verbose) {
244245
* @param allowedListIps Comma-separated list of remote IPv4 addresses.
245246
* @return A self reference.
246247
*/
247-
public Builder withAllowedListIps(String allowedListIps) {
248+
public Builder withAllowedListIps(@Nullable String allowedListIps) {
248249
this.allowedListIps = allowedListIps;
249250
return this;
250251
}
@@ -255,7 +256,7 @@ public Builder withAllowedListIps(String allowedListIps) {
255256
* @param readableTimestamp Whether the timestamp of the log is readable.
256257
* @return A self reference.
257258
*/
258-
public Builder withReadableTimestamp(Boolean readableTimestamp) {
259+
public Builder withReadableTimestamp(@Nullable Boolean readableTimestamp) {
259260
this.readableTimestamp = readableTimestamp;
260261
return this;
261262
}
@@ -321,7 +322,11 @@ protected List<String> createArgs() {
321322

322323
@Override
323324
protected ChromeDriverService createDriverService(
324-
File exe, int port, Duration timeout, List<String> args, Map<String, String> environment) {
325+
@Nullable File exe,
326+
int port,
327+
@Nullable Duration timeout,
328+
@Nullable List<String> args,
329+
@Nullable Map<String, String> environment) {
325330
try {
326331
return new ChromeDriverService(exe, port, timeout, args, environment);
327332
} catch (IOException e) {

0 commit comments

Comments
 (0)