diff --git a/java/src/org/openqa/selenium/Proxy.java b/java/src/org/openqa/selenium/Proxy.java
index 345256444c4a0..e85a0d39eed52 100644
--- a/java/src/org/openqa/selenium/Proxy.java
+++ b/java/src/org/openqa/selenium/Proxy.java
@@ -26,6 +26,8 @@
import java.util.Optional;
import java.util.function.Consumer;
import java.util.stream.Collectors;
+import org.jspecify.annotations.NullMarked;
+import org.jspecify.annotations.Nullable;
/**
* Configuration parameters for using proxies in WebDriver. Generally you should pass an object of
@@ -34,6 +36,7 @@
* configuration. That is, it is an error to set an httpProxy manually and then turn on
* proxy autodetect.
*/
+@NullMarked
public class Proxy {
public enum ProxyType {
@@ -77,15 +80,15 @@ public String toString() {
private ProxyType proxyType = ProxyType.UNSPECIFIED;
private boolean autodetect = false;
- private String ftpProxy;
- private String httpProxy;
- private String noProxy;
- private String sslProxy;
- private String socksProxy;
- private Integer socksVersion;
- private String socksUsername;
- private String socksPassword;
- private String proxyAutoconfigUrl;
+ private @Nullable String ftpProxy;
+ private @Nullable String httpProxy;
+ private @Nullable String noProxy;
+ private @Nullable String sslProxy;
+ private @Nullable String socksProxy;
+ private @Nullable Integer socksVersion;
+ private @Nullable String socksUsername;
+ private @Nullable String socksPassword;
+ private @Nullable String proxyAutoconfigUrl;
public Proxy() {
// Empty default constructor
@@ -120,7 +123,7 @@ public Proxy(Map raw) {
setters.put(AUTODETECT, value -> setAutodetect((Boolean) value));
raw.forEach(
(key, value) -> {
- if (key != null && value != null) {
+ if (key != null && value != null && setters.containsKey(key)) {
setters.get(key).accept(value);
}
});
@@ -223,7 +226,7 @@ public Proxy setAutodetect(boolean autodetect) {
*
* @return the FTP proxy hostname if present, or null if not set
*/
- public String getFtpProxy() {
+ public @Nullable String getFtpProxy() {
return ftpProxy;
}
@@ -245,7 +248,7 @@ public Proxy setFtpProxy(String ftpProxy) {
*
* @return the HTTP proxy hostname if present, or null if not set
*/
- public String getHttpProxy() {
+ public @Nullable String getHttpProxy() {
return httpProxy;
}
@@ -267,7 +270,7 @@ public Proxy setHttpProxy(String httpProxy) {
*
* @return The proxy bypass (noproxy) addresses
*/
- public String getNoProxy() {
+ public @Nullable String getNoProxy() {
return noProxy;
}
@@ -289,7 +292,7 @@ public Proxy setNoProxy(String noProxy) {
*
* @return the SSL tunnel proxy hostname if present, null otherwise
*/
- public String getSslProxy() {
+ public @Nullable String getSslProxy() {
return sslProxy;
}
@@ -311,7 +314,7 @@ public Proxy setSslProxy(String sslProxy) {
*
* @return the SOCKS proxy if present, null otherwise
*/
- public String getSocksProxy() {
+ public @Nullable String getSocksProxy() {
return socksProxy;
}
@@ -333,7 +336,7 @@ public Proxy setSocksProxy(String socksProxy) {
*
* @return the SOCKS version if present, null otherwise
*/
- public Integer getSocksVersion() {
+ public @Nullable Integer getSocksVersion() {
return socksVersion;
}
@@ -355,7 +358,7 @@ public Proxy setSocksVersion(Integer socksVersion) {
*
* @return the SOCKS proxy's username
*/
- public String getSocksUsername() {
+ public @Nullable String getSocksUsername() {
return socksUsername;
}
@@ -377,7 +380,7 @@ public Proxy setSocksUsername(String username) {
*
* @return the SOCKS proxy's password
*/
- public String getSocksPassword() {
+ public @Nullable String getSocksPassword() {
return socksPassword;
}
@@ -399,7 +402,7 @@ public Proxy setSocksPassword(String password) {
*
* @return the proxy auto-configuration URL
*/
- public String getProxyAutoconfigUrl() {
+ public @Nullable String getProxyAutoconfigUrl() {
return proxyAutoconfigUrl;
}
@@ -428,7 +431,7 @@ private void verifyProxyTypeCompatibility(ProxyType compatibleProxy) {
}
@SuppressWarnings({"unchecked"})
- public static Proxy extractFrom(Capabilities capabilities) {
+ public static @Nullable Proxy extractFrom(Capabilities capabilities) {
Object rawProxy = capabilities.getCapability("proxy");
Proxy proxy = null;
if (rawProxy != null) {
@@ -472,7 +475,7 @@ public String toString() {
}
@Override
- public boolean equals(Object o) {
+ public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}
diff --git a/java/src/org/openqa/selenium/print/PageMargin.java b/java/src/org/openqa/selenium/print/PageMargin.java
index 46c2fb1bcef2d..cf4dc68e0ae95 100644
--- a/java/src/org/openqa/selenium/print/PageMargin.java
+++ b/java/src/org/openqa/selenium/print/PageMargin.java
@@ -19,7 +19,9 @@
import java.util.HashMap;
import java.util.Map;
+import org.jspecify.annotations.NullMarked;
+@NullMarked
public class PageMargin {
private final double top;
private final double bottom;
diff --git a/java/src/org/openqa/selenium/print/PageSize.java b/java/src/org/openqa/selenium/print/PageSize.java
index c9c3d78908b12..664a336ff1edc 100644
--- a/java/src/org/openqa/selenium/print/PageSize.java
+++ b/java/src/org/openqa/selenium/print/PageSize.java
@@ -19,7 +19,9 @@
import java.util.HashMap;
import java.util.Map;
+import org.jspecify.annotations.NullMarked;
+@NullMarked
public class PageSize {
private final double height;
diff --git a/java/src/org/openqa/selenium/print/PrintOptions.java b/java/src/org/openqa/selenium/print/PrintOptions.java
index 16592a8bec1d3..8e0484f24ecd3 100644
--- a/java/src/org/openqa/selenium/print/PrintOptions.java
+++ b/java/src/org/openqa/selenium/print/PrintOptions.java
@@ -20,8 +20,11 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.jspecify.annotations.NullMarked;
+import org.jspecify.annotations.Nullable;
import org.openqa.selenium.internal.Require;
+@NullMarked
public class PrintOptions {
public enum Orientation {
@@ -46,7 +49,7 @@ public String toString() {
private boolean shrinkToFit = true;
private PageSize pageSize = new PageSize();
private PageMargin pageMargin = new PageMargin();
- private String[] pageRanges;
+ private String @Nullable [] pageRanges;
public Orientation getOrientation() {
return this.orientation;
@@ -56,7 +59,7 @@ public void setOrientation(Orientation orientation) {
this.orientation = Require.nonNull("orientation", orientation);
}
- public String[] getPageRanges() {
+ public String @Nullable [] getPageRanges() {
return this.pageRanges;
}