Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 24 additions & 21 deletions java/src/org/openqa/selenium/Proxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -34,6 +36,7 @@
* configuration. That is, it is an error to set an <code>httpProxy</code> manually and then turn on
* proxy autodetect.
*/
@NullMarked
public class Proxy {

public enum ProxyType {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -120,7 +123,7 @@ public Proxy(Map<String, ?> 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);
}
});
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -267,7 +270,7 @@ public Proxy setHttpProxy(String httpProxy) {
*
* @return The proxy bypass (noproxy) addresses
*/
public String getNoProxy() {
public @Nullable String getNoProxy() {
return noProxy;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -355,7 +358,7 @@ public Proxy setSocksVersion(Integer socksVersion) {
*
* @return the SOCKS proxy's username
*/
public String getSocksUsername() {
public @Nullable String getSocksUsername() {
return socksUsername;
}

Expand All @@ -377,7 +380,7 @@ public Proxy setSocksUsername(String username) {
*
* @return the SOCKS proxy's password
*/
public String getSocksPassword() {
public @Nullable String getSocksPassword() {
return socksPassword;
}

Expand All @@ -399,7 +402,7 @@ public Proxy setSocksPassword(String password) {
*
* @return the proxy auto-configuration URL
*/
public String getProxyAutoconfigUrl() {
public @Nullable String getProxyAutoconfigUrl() {
return proxyAutoconfigUrl;
}

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -472,7 +475,7 @@ public String toString() {
}

@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}
Expand Down
2 changes: 2 additions & 0 deletions java/src/org/openqa/selenium/print/PageMargin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions java/src/org/openqa/selenium/print/PageSize.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 5 additions & 2 deletions java/src/org/openqa/selenium/print/PrintOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
Expand All @@ -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;
}

Expand Down