Skip to content

Commit 49084ad

Browse files
iampopovichdiemol
andauthored
[java] Feat 14291/jspecify nullable annotation edge driver service (#15972)
* Add Nullable annotations to Builder class fields in EdgeDriverService * Add Nullable annotations to parameters in EdgeDriverService and DriverService constructors * Refactor EdgeDriverService class documentation and structure * Add dependency on jspecify for EdgeDriver --------- Co-authored-by: Diego Molina <diemol@users.noreply.github.com>
1 parent f993bfe commit 49084ad

File tree

3 files changed

+25
-19
lines changed

3 files changed

+25
-19
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ java_export(
2121
"//java/src/org/openqa/selenium/chromium",
2222
"//java/src/org/openqa/selenium/manager",
2323
"//java/src/org/openqa/selenium/remote",
24+
"@maven//:org_jspecify_jspecify",
2425
],
2526
)

java/src/org/openqa/selenium/edge/EdgeDriverService.java

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.util.List;
3030
import java.util.Locale;
3131
import java.util.Map;
32+
import org.jspecify.annotations.Nullable;
3233
import org.openqa.selenium.Capabilities;
3334
import org.openqa.selenium.WebDriverException;
3435
import org.openqa.selenium.chromium.ChromiumDriverLogLevel;
@@ -96,11 +97,11 @@ public class EdgeDriverService extends DriverService {
9697
* @throws IOException If an I/O error occurs.
9798
*/
9899
public EdgeDriverService(
99-
File executable,
100+
@Nullable File executable,
100101
int port,
101-
Duration timeout,
102-
List<String> args,
103-
Map<String, String> environment)
102+
@Nullable Duration timeout,
103+
@Nullable List<String> args,
104+
@Nullable Map<String, String> environment)
104105
throws IOException {
105106
super(executable, port, timeout, List.copyOf(args), Map.copyOf(environment));
106107
}
@@ -139,13 +140,13 @@ public static EdgeDriverService createDefaultService() {
139140
@AutoService(DriverService.Builder.class)
140141
public static class Builder extends DriverService.Builder<EdgeDriverService, Builder> {
141142

142-
private Boolean disableBuildCheck;
143-
private Boolean readableTimestamp;
144-
private Boolean appendLog;
145-
private Boolean verbose;
146-
private Boolean silent;
147-
private String allowedListIps;
148-
private ChromiumDriverLogLevel logLevel;
143+
@Nullable private Boolean disableBuildCheck;
144+
@Nullable private Boolean readableTimestamp;
145+
@Nullable private Boolean appendLog;
146+
@Nullable private Boolean verbose;
147+
@Nullable private Boolean silent;
148+
@Nullable private String allowedListIps;
149+
@Nullable private ChromiumDriverLogLevel logLevel;
149150

150151
@Override
151152
public int score(Capabilities capabilities) {
@@ -196,7 +197,7 @@ public Builder withBuildCheckDisabled(boolean noBuildCheck) {
196197
* @param logLevel {@link ChromiumDriverLogLevel} for desired log level output.
197198
* @return A self reference.
198199
*/
199-
public Builder withLoglevel(ChromiumDriverLogLevel logLevel) {
200+
public Builder withLoglevel(@Nullable ChromiumDriverLogLevel logLevel) {
200201
this.logLevel = logLevel;
201202
this.silent = false;
202203
this.verbose = false;
@@ -238,7 +239,7 @@ public Builder withVerbose(boolean verbose) {
238239
* @param allowedListIps Comma-separated list of remote IPv4 addresses.
239240
* @return A self reference.
240241
*/
241-
public Builder withAllowedListIps(String allowedListIps) {
242+
public Builder withAllowedListIps(@Nullable String allowedListIps) {
242243
this.allowedListIps = allowedListIps;
243244
return this;
244245
}
@@ -249,7 +250,7 @@ public Builder withAllowedListIps(String allowedListIps) {
249250
* @param readableTimestamp Whether the timestamp of the log is readable.
250251
* @return A self reference.
251252
*/
252-
public Builder withReadableTimestamp(Boolean readableTimestamp) {
253+
public Builder withReadableTimestamp(@Nullable Boolean readableTimestamp) {
253254
this.readableTimestamp = readableTimestamp;
254255
return this;
255256
}
@@ -321,7 +322,11 @@ protected List<String> createArgs() {
321322

322323
@Override
323324
protected EdgeDriverService 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 EdgeDriverService(exe, port, timeout, args, environment);
327332
} catch (IOException e) {

java/src/org/openqa/selenium/remote/service/DriverService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,11 @@ public class DriverService implements Closeable {
106106
* @throws IOException If an I/O error occurs.
107107
*/
108108
protected DriverService(
109-
File executable,
109+
@Nullable File executable,
110110
int port,
111-
Duration timeout,
112-
List<String> args,
113-
Map<String, String> environment)
111+
@Nullable Duration timeout,
112+
@Nullable List<String> args,
113+
@Nullable Map<String, String> environment)
114114
throws IOException {
115115
if (executable != null) {
116116
this.executable = executable.getCanonicalPath();

0 commit comments

Comments
 (0)