Skip to content

[java] added jspecify annotations Nullable and NullMarked to exception classes #16024

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 1 commit into
base: trunk
Choose a base branch
from

Conversation

iampopovich
Copy link
Contributor

@iampopovich iampopovich commented Jul 8, 2025

User description

🔗 Related Issues

partially fixes #14291

💥 What does this PR do?

This pull request adds annotations to classes that extend WebDriverException.

To make the changes easier to review, I have split the task of annotating all exception classes into several smaller pull requests. This PR contains updates for 5-7 classes.

🔧 Implementation Notes

This pull request introduces updates to exception classes in the Selenium Java package to improve null safety by integrating jspecify annotations. The changes include marking classes with @NullMarked and updating method parameters to use @Nullable where applicable.

💡 Additional Considerations

🔄 Types of changes

  • Cleanup (formatting, renaming)

PR Type

Enhancement


Description

  • Add @NullMarked annotations to 7 exception classes

  • Add @Nullable annotations to constructor parameters

  • Improve null safety with jspecify annotations

  • Part of larger effort to annotate all exception classes


Changes diagram

flowchart LR
  A["Exception Classes"] --> B["Add @NullMarked"]
  A --> C["Add @Nullable to parameters"]
  B --> D["Improved null safety"]
  C --> D
Loading

Changes walkthrough 📝

Relevant files
Enhancement
7 files
DetachedShadowRootException.java
Add null safety annotations                                                           
+6/-2     
ElementClickInterceptedException.java
Add null safety annotations                                                           
+6/-2     
HealthCheckFailedException.java
Add nullable parameter annotations                                             
+3/-1     
InsecureCertificateException.java
Add null safety annotations                                                           
+7/-3     
InvalidArgumentException.java
Add null safety annotations                                                           
+6/-2     
InvalidElementStateException.java
Add null safety annotations                                                           
+7/-3     
UnsupportedCommandException.java
Add null safety annotations                                                           
+7/-3     

Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • Copy link
    Contributor

    qodo-merge-pro bot commented Jul 8, 2025

    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 review

    Missing Annotation

    This class is missing the @NullMarked annotation that is present in all other exception classes in this PR, which creates inconsistency in the null safety approach.

    public class HealthCheckFailedException extends WebDriverException {

    Copy link
    Contributor

    qodo-merge-pro bot commented Jul 8, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    General
    Add missing NullMarked annotation

    Add the @NullMarked annotation to the class to maintain consistency with other
    exception classes in this PR. This ensures uniform null safety annotation
    coverage across all exception classes.

    java/src/org/openqa/selenium/HealthCheckFailedException.java [20-23]

    +import org.jspecify.annotations.NullMarked;
     import org.jspecify.annotations.Nullable;
     
     /** Indicates that a Node health check failed. */
    +@NullMarked
     public class HealthCheckFailedException extends WebDriverException {
    • Apply / Chat
    Suggestion importance[1-10]: 7

    __

    Why: The suggestion correctly identifies that the @NullMarked annotation is missing on the HealthCheckFailedException class, which is inconsistent with all other exception classes modified in this PR.

    Medium
    • More

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    [🚀 Feature]: JSpecify Nullness annotations for Java
    2 participants