Skip to content

Commit 02d69aa

Browse files
iampopovichdiemol
andauthored
[java] Add JSpecify nullable annotations to exception classes (#16026)
* Add JSpecify nullable annotations to exception classes * fix dependencies on jspecify * add dependency jspecify to build bazel --------- Co-authored-by: Diego Molina <diemol@users.noreply.github.com>
1 parent e30dc4a commit 02d69aa

File tree

6 files changed

+33
-15
lines changed

6 files changed

+33
-15
lines changed

java/src/org/openqa/selenium/InvalidCookieDomainException.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,27 @@
1717

1818
package org.openqa.selenium;
1919

20+
import org.jspecify.annotations.NullMarked;
21+
import org.jspecify.annotations.Nullable;
22+
2023
/**
2124
* Thrown when attempting to add a cookie under a different domain than the current URL.
2225
*
2326
* @see org.openqa.selenium.WebDriver.Options#addCookie(Cookie)
2427
*/
28+
@NullMarked
2529
public class InvalidCookieDomainException extends WebDriverException {
2630
public InvalidCookieDomainException() {}
2731

28-
public InvalidCookieDomainException(String message) {
32+
public InvalidCookieDomainException(@Nullable String message) {
2933
super(message);
3034
}
3135

32-
public InvalidCookieDomainException(Throwable cause) {
36+
public InvalidCookieDomainException(@Nullable Throwable cause) {
3337
super(cause);
3438
}
3539

36-
public InvalidCookieDomainException(String message, Throwable cause) {
40+
public InvalidCookieDomainException(@Nullable String message, @Nullable Throwable cause) {
3741
super(message, cause);
3842
}
3943
}

java/src/org/openqa/selenium/UnableToSetCookieException.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,27 @@
1717

1818
package org.openqa.selenium;
1919

20+
import org.jspecify.annotations.NullMarked;
21+
import org.jspecify.annotations.Nullable;
22+
2023
/**
2124
* Thrown when a driver fails to set a cookie.
2225
*
2326
* @see org.openqa.selenium.WebDriver.Options#addCookie(Cookie)
2427
*/
28+
@NullMarked
2529
public class UnableToSetCookieException extends WebDriverException {
2630
public UnableToSetCookieException() {}
2731

28-
public UnableToSetCookieException(String message) {
32+
public UnableToSetCookieException(@Nullable String message) {
2933
super(message);
3034
}
3135

32-
public UnableToSetCookieException(Throwable cause) {
36+
public UnableToSetCookieException(@Nullable Throwable cause) {
3337
super(cause);
3438
}
3539

36-
public UnableToSetCookieException(String message, Throwable cause) {
40+
public UnableToSetCookieException(@Nullable String message, @Nullable Throwable cause) {
3741
super(message, cause);
3842
}
3943
}

java/src/org/openqa/selenium/devtools/DevToolsException.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,22 @@
1717

1818
package org.openqa.selenium.devtools;
1919

20+
import org.jspecify.annotations.NullMarked;
21+
import org.jspecify.annotations.Nullable;
2022
import org.openqa.selenium.WebDriverException;
2123

24+
@NullMarked
2225
public class DevToolsException extends WebDriverException {
2326

24-
public DevToolsException(Throwable cause) {
27+
public DevToolsException(@Nullable Throwable cause) {
2528
this(cause.getMessage(), cause);
2629
}
2730

28-
public DevToolsException(String message) {
31+
public DevToolsException(@Nullable String message) {
2932
this(message, null);
3033
}
3134

32-
public DevToolsException(String message, Throwable cause) {
35+
public DevToolsException(@Nullable String message, @Nullable Throwable cause) {
3336
super(message, cause);
3437
addInfo(WebDriverException.DRIVER_INFO, "DevTools Connection");
3538
}

java/src/org/openqa/selenium/json/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ java_export(
1414
],
1515
deps = [
1616
"//java/src/org/openqa/selenium:core",
17+
"@maven//:org_jspecify_jspecify",
1718
],
1819
)

java/src/org/openqa/selenium/json/JsonException.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,22 @@
1717

1818
package org.openqa.selenium.json;
1919

20+
import org.jspecify.annotations.NullMarked;
21+
import org.jspecify.annotations.Nullable;
2022
import org.openqa.selenium.WebDriverException;
2123

24+
@NullMarked
2225
public class JsonException extends WebDriverException {
2326

24-
public JsonException(String message) {
27+
public JsonException(@Nullable String message) {
2528
super(message);
2629
}
2730

28-
public JsonException(Throwable cause) {
31+
public JsonException(@Nullable Throwable cause) {
2932
super(cause);
3033
}
3134

32-
public JsonException(String message, Throwable cause) {
35+
public JsonException(@Nullable String message, @Nullable Throwable cause) {
3336
super(message, cause);
3437
}
3538
}

java/src/org/openqa/selenium/remote/ScreenshotException.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,22 @@
1717

1818
package org.openqa.selenium.remote;
1919

20+
import org.jspecify.annotations.NullMarked;
21+
import org.jspecify.annotations.Nullable;
2022
import org.openqa.selenium.WebDriverException;
2123

24+
@NullMarked
2225
public class ScreenshotException extends WebDriverException {
2326

24-
public ScreenshotException(String message) {
27+
public ScreenshotException(@Nullable String message) {
2528
super(message);
2629
}
2730

28-
public ScreenshotException(Throwable cause) {
31+
public ScreenshotException(@Nullable Throwable cause) {
2932
super(cause);
3033
}
3134

32-
public ScreenshotException(String message, Throwable cause) {
35+
public ScreenshotException(@Nullable String message, @Nullable Throwable cause) {
3336
super(message, cause);
3437
}
3538
}

0 commit comments

Comments
 (0)