Skip to content

Commit 7253b08

Browse files
authored
Merge branch 'trunk' into replace-string-equals
2 parents 8d9f68f + 3383f43 commit 7253b08

32 files changed

+2057
-2976
lines changed

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ bazel_dep(name = "rules_ruby", version = "0.19.0")
3131
# Until `rules_jvm_external` 6.8 ships
3232
git_override(
3333
module_name = "rules_jvm_external",
34-
commit = "29c451d2a62aa2451f5810c005ecac925b4772b6",
34+
commit = "aca619b117c1fe306ffdd20c5f47cc4dbd5effed",
3535
patch_strip = 1,
3636
patches = ["//java:rules_jvm_external_javadoc.patch"],
3737
remote = "https://github.com/bazel-contrib/rules_jvm_external.git",

java/src/org/openqa/selenium/By.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ public String toString() {
296296

297297
public static class ByClassName extends PreW3CLocator {
298298

299+
private static final Pattern AT_LEAST_ONE_WHITESPACE = Pattern.compile(".*\\s.*");
299300
private final String className;
300301

301302
public ByClassName(String className) {
@@ -305,7 +306,7 @@ public ByClassName(String className) {
305306
.nonNull("Cannot find elements when the class name expression is null."),
306307
".%s");
307308

308-
if (className.matches(".*\\s.*")) {
309+
if (AT_LEAST_ONE_WHITESPACE.matcher(className).matches()) {
309310
throw new InvalidSelectorException("Compound class names not permitted");
310311
}
311312

java/src/org/openqa/selenium/PersistentCapabilities.java

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@
1717

1818
package org.openqa.selenium;
1919

20-
import java.util.Collections;
2120
import java.util.Map;
2221
import java.util.Set;
2322
import java.util.function.Function;
24-
import java.util.stream.Collector;
2523
import java.util.stream.Collectors;
2624
import java.util.stream.Stream;
2725
import org.openqa.selenium.internal.Require;
@@ -58,7 +56,7 @@ public PersistentCapabilities setCapability(String name, Object value) {
5856
@Override
5957
public Map<String, Object> asMap() {
6058
return getCapabilityNames().stream()
61-
.collect(toUnmodifiableMap(Function.identity(), this::getCapability));
59+
.collect(Collectors.toUnmodifiableMap(Function.identity(), this::getCapability));
6260
}
6361

6462
@Override
@@ -81,19 +79,7 @@ public Capabilities merge(Capabilities other) {
8179
public Set<String> getCapabilityNames() {
8280
return Stream.concat(
8381
caps.getCapabilityNames().stream(), overrides.getCapabilityNames().stream())
84-
.collect(toUnmodifiableSet());
85-
}
86-
87-
// Needed, since we're dependent on Java 8 as a minimum version
88-
private <T, K, U> Collector<T, ?, Map<K, U>> toUnmodifiableMap(
89-
Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends U> valueMapper) {
90-
return Collectors.collectingAndThen(
91-
Collectors.toMap(keyMapper, valueMapper), Collections::unmodifiableMap);
92-
}
93-
94-
// Needed, since we're dependent on Java 8 as a minimum version
95-
private <T> Collector<T, ?, Set<T>> toUnmodifiableSet() {
96-
return Collectors.collectingAndThen(Collectors.toSet(), Collections::unmodifiableSet);
82+
.collect(Collectors.toUnmodifiableSet());
9783
}
9884

9985
@Override

java/src/org/openqa/selenium/Platform.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ public String toString() {
369369
}
370370
};
371371

372+
private static final Pattern VERSION_PATTERN = Pattern.compile("^(\\d+)\\.(\\d+).*");
372373
private static @Nullable Platform current;
373374
private final String[] partOfOsName;
374375
private int minorVersion = 0;
@@ -389,21 +390,20 @@ public static Platform getCurrent() {
389390

390391
String version = System.getProperty("os.version", "0.0.0");
391392
int major = 0;
392-
int min = 0;
393+
int minor = 0;
393394

394-
Pattern pattern = Pattern.compile("^(\\d+)\\.(\\d+).*");
395-
Matcher matcher = pattern.matcher(version);
395+
final Matcher matcher = VERSION_PATTERN.matcher(version);
396396
if (matcher.matches()) {
397397
try {
398398
major = Integer.parseInt(matcher.group(1));
399-
min = Integer.parseInt(matcher.group(2));
399+
minor = Integer.parseInt(matcher.group(2));
400400
} catch (NumberFormatException e) {
401401
// These things happen
402402
}
403403
}
404404

405405
current.majorVersion = major;
406-
current.minorVersion = min;
406+
current.minorVersion = minor;
407407
}
408408
return current;
409409
}

java/src/org/openqa/selenium/Point.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
import org.jspecify.annotations.NullMarked;
2222
import org.jspecify.annotations.Nullable;
2323

24-
/** A copy of java.awt.Point, to remove dependency on awt. */
24+
/** Represents a point in a two-dimensional space with x and y coordinates. */
2525
@NullMarked
2626
public class Point {
27-
public int x;
28-
public int y;
27+
public final int x;
28+
public final int y;
2929

3030
public Point(int x, int y) {
3131
this.x = x;

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) {

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) {

0 commit comments

Comments
 (0)