[java] Add JSpecify nullable annotations to exception classes pt2
User description
🔗 Related Issues
partially fixes #14291
💥 What does this PR do?
same as #16024
🔧 Implementation Notes
This pull request introduces nullability annotations to improve type safety and clarify the handling of nullable values in several exception classes within the Selenium Java codebase. The changes ensure that parameters and fields that can accept or return null are explicitly marked as nullable, while the classes themselves are marked as null-safe.
Nullability Annotations Added to Exception Classes:
-
NoSuchSessionException:- Added
@NullMarkedannotation to the class. - Marked the
reasonparameter in constructors as@Nullable.
- Added
-
ScriptTimeoutException:- Added
@NullMarkedannotation to the class. - Marked the
messageandcauseparameters in constructors as@Nullable.
- Added
-
SessionNotCreatedException:- Added
@NullMarkedannotation to the class. - Marked the
msgandcauseparameters in constructors as@Nullable.
- Added
-
TimeoutException:- Added
@NullMarkedannotation to the class. - Marked the
messageandcauseparameters in constructors as@Nullable.
- Added
-
UnhandledAlertException:- Added
@NullMarkedannotation to the class. - Marked the
alertTextfield and themessageandalertTextparameters in constructors as@Nullable. - Updated the
getAlertTextmethod to return@Nullable.
- Added
💡 Additional Considerations
🔄 Types of changes
- Cleanup (formatting, renaming)
PR Type
Enhancement
Description
-
Added JSpecify nullability annotations to exception classes
-
Marked classes as
@NullMarkedfor null safety -
Annotated constructor parameters and fields as
@Nullable -
Enhanced type safety for exception handling
Changes diagram
flowchart LR
A["Exception Classes"] --> B["@NullMarked Annotation"]
A --> C["@Nullable Parameters"]
B --> D["Type Safety"]
C --> D
Changes walkthrough 📝
| Relevant files | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Enhancement |
|
Need help?
Type /help how to ...in the comments thread for any questions about Qodo Merge usage.Check out the documentation for more information.
PR Reviewer Guide 🔍
Here are some key observations to aid the review process:
| ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪ |
| 🧪 No relevant tests |
| 🔒 No security concerns identified |
⚡ Recommended focus areas for reviewNull Handling
msg parameter directly in string operations without null checks, which could result in "null" being displayed in error messages when msg is null. |
PR Code Suggestions ✨
Explore these optional code suggestions:
| Category | Suggestion | Impact |
| General |
Handle null string concatenation safelyThe string concatenation with a nullable java/src/org/openqa/selenium/SessionNotCreatedException.java [26-31]
Suggestion importance[1-10]: 7__ Why: The suggestion correctly identifies that concatenating a | Medium |
| ||