selenium icon indicating copy to clipboard operation
selenium copied to clipboard

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

Open iampopovich opened this issue 5 months ago • 3 comments

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

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.
  • iampopovich avatar Jul 08 '25 19:07 iampopovich

    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 {
    
    

    qodo-code-review[bot] avatar Jul 08 '25 19:07 qodo-code-review[bot]

    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
    • [ ] Update

    qodo-code-review[bot] avatar Jul 08 '25 19:07 qodo-code-review[bot]

    @pujagani check please🙏

    iampopovich avatar Oct 24 '25 13:10 iampopovich