Skip to content

Add JSpecify nullable annotations to exception classes #16027

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.openqa.selenium.devtools;

import org.jspecify.annotations.NullMarked;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.remote.http.Filter;
import org.openqa.selenium.remote.http.HttpHandler;
Expand All @@ -26,4 +27,5 @@
* browser fails to send a HTTP request. It can be caught in a {@link Filter} to handle the error
* by, for example, returning a custom HTTP response.
*/
@NullMarked
public class RequestFailedException extends WebDriverException {}
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,25 @@

package org.openqa.selenium.grid.sessionmap.jdbc;

import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import org.openqa.selenium.WebDriverException;

@NullMarked
public class JdbcException extends WebDriverException {
public JdbcException() {
super();
}

public JdbcException(String message) {
public JdbcException(@Nullable String message) {
super(message);
}

public JdbcException(Throwable cause) {
public JdbcException(@Nullable Throwable cause) {
super(cause);
}

public JdbcException(String message, Throwable cause) {
public JdbcException(@Nullable String message, @Nullable Throwable cause) {
super(message, cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,22 @@

package org.openqa.selenium.remote;

import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.remote.service.DriverFinder;

/** Thrown by {@link DriverFinder#getDriverPath()} (DriverService, Capabilities)}. */
@NullMarked
public class NoSuchDriverException extends WebDriverException {

private static final String SUPPORT_URL = BASE_SUPPORT_URL + "/driver_location/";

public NoSuchDriverException(String reason) {
public NoSuchDriverException(@Nullable String reason) {
super(reason);
}

public NoSuchDriverException(String reason, Throwable cause) {
public NoSuchDriverException(@Nullable String reason, @Nullable Throwable cause) {
super(reason, cause);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.openqa.selenium.remote;

import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import org.openqa.selenium.WebDriverException;

/**
Expand All @@ -33,12 +35,13 @@
*
* 1)
*/
@NullMarked
public class UnreachableBrowserException extends WebDriverException {
public UnreachableBrowserException(String message) {
public UnreachableBrowserException(@Nullable String message) {
super(message);
}

public UnreachableBrowserException(String message, Throwable cause) {
public UnreachableBrowserException(@Nullable String message, @Nullable Throwable cause) {
super(message, cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@

package org.openqa.selenium.remote.http;

import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import org.openqa.selenium.WebDriverException;

@NullMarked
public class ConnectionFailedException extends WebDriverException {

public ConnectionFailedException(String message) {
public ConnectionFailedException(@Nullable String message) {
super(message);
}

public ConnectionFailedException(String message, Throwable cause) {
public ConnectionFailedException(@Nullable String message, @Nullable Throwable cause) {
super(message, cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@

package org.openqa.selenium.safari;

import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import org.openqa.selenium.WebDriverException;

/** Exception thrown when the connection to the SafariDriver is lost. */
@NullMarked
public class ConnectionClosedException extends WebDriverException {

public ConnectionClosedException(String message) {
public ConnectionClosedException(@Nullable String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@

package org.openqa.selenium.support.ui;

import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import org.openqa.selenium.WebDriverException;

@NullMarked
public class UnexpectedTagNameException extends WebDriverException {
public UnexpectedTagNameException(String expectedTagName, String actualTagName) {
public UnexpectedTagNameException(
@Nullable String expectedTagName, @Nullable String actualTagName) {
super(
String.format(
"Element should have been \"%s\" but was \"%s\"", expectedTagName, actualTagName));
Expand Down