[java] Feat 14291/jspecify nullable annotation edge driver service by iampopovich ยท Pull Request #15972 ยท SeleniumHQ/selenium

User description

๐Ÿ”— Related Issues

fixes #14291

๐Ÿ’ฅ What does this PR do?

This pull request introduces changes to the EdgeDriverService and its parent class DriverService to improve nullability handling by adding @Nullable annotations to various parameters and fields. These changes enhance type safety and make the codebase more robust when dealing with potentially null values.

๐Ÿ”ง Implementation Notes

Nullability Enhancements in EdgeDriverService:

  • Added @Nullable annotations to parameters in the EdgeDriverService constructor, including File executable, Duration timeout, List<String> args, and Map<String, String> environment. This ensures better handling of optional values during service creation.
  • Updated the Builder class fields (e.g., disableBuildCheck, logLevel, allowedListIps) with @Nullable annotations to explicitly mark them as optional.
  • Modified methods in the Builder class, such as withLoglevel and withAllowedListIps, to include @Nullable annotations for their parameters, improving clarity about optional inputs. [1] [2] [3]
  • Adjusted the createDriverService method in EdgeDriverService to use @Nullable annotations for its parameters, aligning with the updated constructor.

Nullability Enhancements in DriverService:

  • Added @Nullable annotations to the DriverService constructor parameters (File executable, Duration timeout, List<String> args, and Map<String, String> environment) to propagate nullability handling to the parent class.

๐Ÿ’ก Additional Considerations

๐Ÿ”„ Types of changes

  • Cleanup (formatting, renaming)

PR Type

Enhancement


Description

  • Add @nullable annotations to EdgeDriverService constructor parameters

  • Add @nullable annotations to Builder class fields and methods

  • Update DriverService constructor with @nullable annotations

  • Add jspecify dependency to BUILD.bazel


Changes diagram

flowchart LR
  A["EdgeDriverService constructor"] -- "add @Nullable" --> B["Parameters: executable, timeout, args, environment"]
  C["Builder class fields"] -- "add @Nullable" --> D["Fields: disableBuildCheck, logLevel, allowedListIps, etc."]
  E["Builder methods"] -- "add @Nullable" --> F["Method parameters: withLoglevel, withAllowedListIps"]
  G["BUILD.bazel"] -- "add dependency" --> H["org_jspecify_jspecify"]
Loading

Changes walkthrough ๐Ÿ“

Relevant files
Enhancement
EdgeDriverService.java
Add @Nullable annotations for null safety                               

java/src/org/openqa/selenium/edge/EdgeDriverService.java

  • Add @nullable annotations to constructor parameters (executable,
    timeout, args, environment)
  • Add @nullable annotations to Builder class fields (disableBuildCheck,
    logLevel, allowedListIps, etc.)
  • Add @nullable annotations to Builder method parameters (withLoglevel,
    withAllowedListIps, withReadableTimestamp)
  • Update createDriverService method signature with @nullable annotations
  • +20/-15 
    DriverService.java
    Add @Nullable annotations to constructor                                 

    java/src/org/openqa/selenium/remote/service/DriverService.java

  • Add @nullable annotations to constructor parameters (executable,
    timeout, args, environment)
  • +4/-4     
    Dependencies
    BUILD.bazel
    Add jspecify dependency                                                                   

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

    • Add jspecify dependency to support @nullable annotations
    +1/-0     

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