Skip to content

[java] Add JSpecify nullable annotations to exception classes pt3 #16026

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

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from
Open
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
10 changes: 7 additions & 3 deletions java/src/org/openqa/selenium/InvalidCookieDomainException.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,27 @@

package org.openqa.selenium;

import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

/**
* Thrown when attempting to add a cookie under a different domain than the current URL.
*
* @see org.openqa.selenium.WebDriver.Options#addCookie(Cookie)
*/
@NullMarked
public class InvalidCookieDomainException extends WebDriverException {
public InvalidCookieDomainException() {}

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

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

public InvalidCookieDomainException(String message, Throwable cause) {
public InvalidCookieDomainException(@Nullable String message, @Nullable Throwable cause) {
super(message, cause);
}
}
10 changes: 7 additions & 3 deletions java/src/org/openqa/selenium/UnableToSetCookieException.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,27 @@

package org.openqa.selenium;

import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

/**
* Thrown when a driver fails to set a cookie.
*
* @see org.openqa.selenium.WebDriver.Options#addCookie(Cookie)
*/
@NullMarked
public class UnableToSetCookieException extends WebDriverException {
public UnableToSetCookieException() {}

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

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

public UnableToSetCookieException(String message, Throwable cause) {
public UnableToSetCookieException(@Nullable String message, @Nullable Throwable cause) {
super(message, cause);
}
}
1 change: 1 addition & 0 deletions java/src/org/openqa/selenium/devtools/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ java_library(
deps = [
"//java/src/org/openqa/selenium:core",
"//java/src/org/openqa/selenium/json",
"@maven//:org_jspecify_jspecify",
],
)

Expand Down
9 changes: 6 additions & 3 deletions java/src/org/openqa/selenium/devtools/DevToolsException.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,22 @@

package org.openqa.selenium.devtools;

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

@NullMarked
public class DevToolsException extends WebDriverException {

public DevToolsException(Throwable cause) {
public DevToolsException(@Nullable Throwable cause) {
this(cause.getMessage(), cause);
}

public DevToolsException(String message) {
public DevToolsException(@Nullable String message) {
this(message, null);
}

public DevToolsException(String message, Throwable cause) {
public DevToolsException(@Nullable String message, @Nullable Throwable cause) {
super(message, cause);
addInfo(WebDriverException.DRIVER_INFO, "DevTools Connection");
}
Expand Down
1 change: 1 addition & 0 deletions java/src/org/openqa/selenium/json/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ java_export(
],
deps = [
"//java/src/org/openqa/selenium:core",
"@maven//:org_jspecify_jspecify",
],
)
9 changes: 6 additions & 3 deletions java/src/org/openqa/selenium/json/JsonException.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,22 @@

package org.openqa.selenium.json;

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

@NullMarked
public class JsonException extends WebDriverException {

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

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

public JsonException(String message, Throwable cause) {
public JsonException(@Nullable String message, @Nullable Throwable cause) {
super(message, cause);
}
}
9 changes: 6 additions & 3 deletions java/src/org/openqa/selenium/remote/ScreenshotException.java
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;

@NullMarked
public class ScreenshotException extends WebDriverException {

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

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

public ScreenshotException(String message, Throwable cause) {
public ScreenshotException(@Nullable String message, @Nullable Throwable cause) {
super(message, cause);
}
}