Skip to content

Commit a691cef

Browse files
authored
Merge branch 'trunk' into py-support-ipv6-only-systems
2 parents ee82768 + 59e1bfc commit a691cef

File tree

17 files changed

+653
-492
lines changed

17 files changed

+653
-492
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ java_export(
1616
"//java/src/org/openqa/selenium/json",
1717
"//java/src/org/openqa/selenium/manager",
1818
"//java/src/org/openqa/selenium/remote",
19+
"@maven//:org_jspecify_jspecify",
1920
],
2021
)

java/src/org/openqa/selenium/firefox/FirefoxDriverService.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.time.Duration;
2323
import java.util.List;
2424
import java.util.Map;
25+
import org.jspecify.annotations.Nullable;
2526
import org.openqa.selenium.remote.service.DriverService;
2627

2728
public abstract class FirefoxDriverService extends DriverService {
@@ -35,11 +36,11 @@ public abstract class FirefoxDriverService extends DriverService {
3536
* @throws IOException If an I/O error occurs.
3637
*/
3738
public FirefoxDriverService(
38-
File executable,
39+
@Nullable File executable,
3940
int port,
40-
Duration timeout,
41-
List<String> args,
42-
Map<String, String> environment)
41+
@Nullable Duration timeout,
42+
@Nullable List<String> args,
43+
@Nullable Map<String, String> environment)
4344
throws IOException {
4445
super(executable, port, timeout, args, environment);
4546
}

java/src/org/openqa/selenium/firefox/GeckoDriverService.java

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import java.util.List;
3333
import java.util.Locale;
3434
import java.util.Map;
35+
import org.jspecify.annotations.Nullable;
3536
import org.openqa.selenium.Capabilities;
3637
import org.openqa.selenium.WebDriverException;
3738
import org.openqa.selenium.net.PortProber;
@@ -83,11 +84,11 @@ public class GeckoDriverService extends FirefoxDriverService {
8384
* @throws IOException If an I/O error occurs.
8485
*/
8586
public GeckoDriverService(
86-
File executable,
87+
@Nullable File executable,
8788
int port,
88-
Duration timeout,
89-
List<String> args,
90-
Map<String, String> environment)
89+
@Nullable Duration timeout,
90+
@Nullable List<String> args,
91+
@Nullable Map<String, String> environment)
9192
throws IOException {
9293
super(
9394
executable,
@@ -142,10 +143,10 @@ protected boolean hasShutdownEndpoint() {
142143
public static class Builder
143144
extends FirefoxDriverService.Builder<GeckoDriverService, GeckoDriverService.Builder> {
144145

145-
private String allowHosts;
146-
private FirefoxDriverLogLevel logLevel;
147-
private Boolean logTruncate;
148-
private File profileRoot;
146+
private @Nullable String allowHosts;
147+
private @Nullable FirefoxDriverLogLevel logLevel;
148+
private @Nullable Boolean logTruncate;
149+
private @Nullable File profileRoot;
149150

150151
@Override
151152
public int score(Capabilities capabilities) {
@@ -168,7 +169,7 @@ public int score(Capabilities capabilities) {
168169
* @param allowHosts Space-separated list of host names.
169170
* @return A self reference.
170171
*/
171-
public Builder withAllowHosts(String allowHosts) {
172+
public Builder withAllowHosts(@Nullable String allowHosts) {
172173
this.allowHosts = allowHosts;
173174
return this;
174175
}
@@ -177,7 +178,7 @@ public Builder withAllowHosts(String allowHosts) {
177178
* @param logLevel which log events to record.
178179
* @return A self reference.
179180
*/
180-
public Builder withLogLevel(FirefoxDriverLogLevel logLevel) {
181+
public Builder withLogLevel(@Nullable FirefoxDriverLogLevel logLevel) {
181182
this.logLevel = logLevel;
182183
return this;
183184
}
@@ -187,7 +188,7 @@ public Builder withLogLevel(FirefoxDriverLogLevel logLevel) {
187188
* default; setting "false" removes truncation
188189
* @return A self reference.
189190
*/
190-
public Builder withTruncatedLogs(Boolean truncate) {
191+
public Builder withTruncatedLogs(@Nullable Boolean truncate) {
191192
this.logTruncate = truncate;
192193
return this;
193194
}
@@ -198,7 +199,7 @@ public Builder withTruncatedLogs(Boolean truncate) {
198199
* @param root location to store temporary profiles Defaults to the system temporary directory.
199200
* @return A self reference.
200201
*/
201-
public GeckoDriverService.Builder withProfileRoot(File root) {
202+
public GeckoDriverService.Builder withProfileRoot(@Nullable File root) {
202203
this.profileRoot = root;
203204
return this;
204205
}
@@ -257,7 +258,11 @@ protected List<String> createArgs() {
257258

258259
@Override
259260
protected GeckoDriverService createDriverService(
260-
File exe, int port, Duration timeout, List<String> args, Map<String, String> environment) {
261+
@Nullable File exe,
262+
int port,
263+
@Nullable Duration timeout,
264+
@Nullable List<String> args,
265+
@Nullable Map<String, String> environment) {
261266
try {
262267
return new GeckoDriverService(exe, port, timeout, args, environment);
263268
} catch (IOException e) {

java/src/org/openqa/selenium/ie/InternetExplorerDriverService.java

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.util.List;
3131
import java.util.Locale;
3232
import java.util.Map;
33+
import org.jspecify.annotations.Nullable;
3334
import org.openqa.selenium.Capabilities;
3435
import org.openqa.selenium.WebDriverException;
3536
import org.openqa.selenium.remote.service.DriverFinder;
@@ -78,11 +79,11 @@ public class InternetExplorerDriverService extends DriverService {
7879
* @throws IOException If an I/O error occurs.
7980
*/
8081
public InternetExplorerDriverService(
81-
File executable,
82+
@Nullable File executable,
8283
int port,
83-
Duration timeout,
84-
List<String> args,
85-
Map<String, String> environment)
84+
@Nullable Duration timeout,
85+
@Nullable List<String> args,
86+
@Nullable Map<String, String> environment)
8687
throws IOException {
8788
super(
8889
executable,
@@ -128,10 +129,10 @@ public static class Builder
128129
extends DriverService.Builder<
129130
InternetExplorerDriverService, InternetExplorerDriverService.Builder> {
130131

131-
private InternetExplorerDriverLogLevel logLevel;
132-
private String host = null;
133-
private File extractPath = null;
134-
private Boolean silent = null;
132+
private @Nullable InternetExplorerDriverLogLevel logLevel;
133+
private @Nullable String host = null;
134+
private @Nullable File extractPath = null;
135+
private @Nullable Boolean silent = null;
135136

136137
@Override
137138
public int score(Capabilities capabilities) {
@@ -154,7 +155,7 @@ public int score(Capabilities capabilities) {
154155
* @param logLevel A level of the log verbosity.
155156
* @return A self reference.
156157
*/
157-
public Builder withLogLevel(InternetExplorerDriverLogLevel logLevel) {
158+
public Builder withLogLevel(@Nullable InternetExplorerDriverLogLevel logLevel) {
158159
this.logLevel = logLevel;
159160
return this;
160161
}
@@ -165,7 +166,7 @@ public Builder withLogLevel(InternetExplorerDriverLogLevel logLevel) {
165166
* @param host A host name.
166167
* @return A self reference.
167168
*/
168-
public Builder withHost(String host) {
169+
public Builder withHost(@Nullable String host) {
169170
this.host = host;
170171
return this;
171172
}
@@ -176,7 +177,7 @@ public Builder withHost(String host) {
176177
* @param extractPath A path.
177178
* @return A self reference.
178179
*/
179-
public Builder withExtractPath(File extractPath) {
180+
public Builder withExtractPath(@Nullable File extractPath) {
180181
this.extractPath = extractPath;
181182
return this;
182183
}
@@ -187,7 +188,7 @@ public Builder withExtractPath(File extractPath) {
187188
* @param silent To be silent in stdout or not.
188189
* @return A self reference.
189190
*/
190-
public Builder withSilent(Boolean silent) {
191+
public Builder withSilent(@Nullable Boolean silent) {
191192
this.silent = silent;
192193
return this;
193194
}
@@ -244,7 +245,11 @@ protected List<String> createArgs() {
244245

245246
@Override
246247
protected InternetExplorerDriverService createDriverService(
247-
File exe, int port, Duration timeout, List<String> args, Map<String, String> environment) {
248+
@Nullable File exe,
249+
int port,
250+
@Nullable Duration timeout,
251+
@Nullable List<String> args,
252+
@Nullable Map<String, String> environment) {
248253
try {
249254
return new InternetExplorerDriverService(exe, port, timeout, args, environment);
250255
} catch (IOException e) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ java_export(
1414
"//java:auto-service",
1515
"//java/src/org/openqa/selenium:core",
1616
"//java/src/org/openqa/selenium/remote",
17+
"@maven//:org_jspecify_jspecify",
1718
],
1819
)

java/src/org/openqa/selenium/safari/SafariDriverService.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import java.util.HashMap;
3333
import java.util.List;
3434
import java.util.Map;
35+
import org.jspecify.annotations.Nullable;
3536
import org.openqa.selenium.Capabilities;
3637
import org.openqa.selenium.WebDriverException;
3738
import org.openqa.selenium.net.PortProber;
@@ -64,11 +65,11 @@ public class SafariDriverService extends DriverService {
6465
* @throws IOException If an I/O error occurs.
6566
*/
6667
public SafariDriverService(
67-
File executable,
68+
@Nullable File executable,
6869
int port,
69-
Duration timeout,
70-
List<String> args,
71-
Map<String, String> environment)
70+
@Nullable Duration timeout,
71+
@Nullable List<String> args,
72+
@Nullable Map<String, String> environment)
7273
throws IOException {
7374
super(
7475
executable,
@@ -126,7 +127,7 @@ protected void waitUntilAvailable() {
126127
public static class Builder
127128
extends DriverService.Builder<SafariDriverService, SafariDriverService.Builder> {
128129

129-
private Boolean diagnose;
130+
private @Nullable Boolean diagnose;
130131

131132
@Override
132133
public int score(Capabilities capabilities) {
@@ -139,13 +140,13 @@ public int score(Capabilities capabilities) {
139140
return score;
140141
}
141142

142-
public Builder withLogging(Boolean logging) {
143+
public Builder withLogging(@Nullable Boolean logging) {
143144
this.diagnose = logging;
144145
return this;
145146
}
146147

147148
@Override
148-
public Builder withLogFile(File logFile) {
149+
public Builder withLogFile(@Nullable File logFile) {
149150
throw new WebDriverException(
150151
"Can not set log location for Safari; use withLogging(true) and locate log in"
151152
+ " ~/Library/Logs/com.apple.WebDriver/");
@@ -169,7 +170,11 @@ protected List<String> createArgs() {
169170

170171
@Override
171172
protected SafariDriverService createDriverService(
172-
File exe, int port, Duration timeout, List<String> args, Map<String, String> environment) {
173+
@Nullable File exe,
174+
int port,
175+
@Nullable Duration timeout,
176+
@Nullable List<String> args,
177+
@Nullable Map<String, String> environment) {
173178
try {
174179
withLogOutput(OutputStream.nullOutputStream());
175180
return new SafariDriverService(exe, port, timeout, args, environment);

java/src/org/openqa/selenium/support/AbstractFindByBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
import java.util.Set;
2323
import org.openqa.selenium.By;
2424

25-
public abstract class AbstractFindByBuilder {
25+
public abstract class AbstractFindByBuilder<T> {
2626

27-
public abstract By buildIt(Object annotation, Field field);
27+
public abstract By buildIt(T annotation, Field field);
2828

2929
protected By buildByFromFindBy(FindBy findBy) {
3030
assertValidFindBy(findBy);

java/src/org/openqa/selenium/support/FindAll.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,9 @@
4545
public @interface FindAll {
4646
FindBy[] value();
4747

48-
class FindByBuilder extends AbstractFindByBuilder {
48+
class FindByBuilder extends AbstractFindByBuilder<FindAll> {
4949
@Override
50-
public By buildIt(Object annotation, Field field) {
51-
FindAll findBys = (FindAll) annotation;
50+
public By buildIt(FindAll findBys, Field field) {
5251
assertValidFindAll(findBys);
5352

5453
FindBy[] findByArray = findBys.value();

java/src/org/openqa/selenium/support/FindBy.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,9 @@
7474

7575
String xpath() default "";
7676

77-
class FindByBuilder extends AbstractFindByBuilder {
77+
class FindByBuilder extends AbstractFindByBuilder<FindBy> {
7878
@Override
79-
public By buildIt(Object annotation, Field field) {
80-
FindBy findBy = (FindBy) annotation;
79+
public By buildIt(FindBy findBy, Field field) {
8180
assertValidFindBy(findBy);
8281

8382
By ans = buildByFromShortFindBy(findBy);

java/src/org/openqa/selenium/support/FindBys.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@
4444
public @interface FindBys {
4545
FindBy[] value();
4646

47-
class FindByBuilder extends AbstractFindByBuilder {
47+
class FindByBuilder extends AbstractFindByBuilder<FindBys> {
4848
@Override
49-
public By buildIt(Object annotation, Field field) {
50-
FindBys findBys = (FindBys) annotation;
49+
public By buildIt(FindBys findBys, Field field) {
5150
assertValidFindBys(findBys);
5251

5352
FindBy[] findByArray = findBys.value();

0 commit comments

Comments
 (0)