Skip to content

Conversation

@iampopovich
Copy link
Contributor

@iampopovich iampopovich commented Jul 5, 2025

User description

🔗 Related Issues

fixes #14291

💥 What does this PR do?

🔧 Implementation Notes

This pull request introduces nullable annotations (@Nullable) to the InternetExplorerDriverService class and its nested Builder class in order to improve type safety and clarify the handling of potentially null values. These changes ensure better compatibility with tools that analyze nullability and enhance code robustness.

Enhancements to nullability:

  • Added @Nullable annotations to constructor parameters: Updated the constructor of InternetExplorerDriverService to mark File, Duration, List<String>, and Map<String, String> parameters as nullable, reflecting their potential to hold null values. ([java/src/org/openqa/selenium/ie/InternetExplorerDriverService.javaL81-R86](https://github.com/SeleniumHQ/selenium/pull/16001/files#diff-617a4c6d0ef39b1c4febbc83065a223bcd42281a33498df32b5e3cef6cb71677L81-R86))
  • Updated fields in the Builder class: Marked the logLevel, host, extractPath, and silent fields as nullable in the Builder class to align with their optional nature. ([java/src/org/openqa/selenium/ie/InternetExplorerDriverService.javaL131-R135](https://github.com/SeleniumHQ/selenium/pull/16001/files#diff-617a4c6d0ef39b1c4febbc83065a223bcd42281a33498df32b5e3cef6cb71677L131-R135))
  • Modified builder methods to accept nullable arguments: Updated methods like withLogLevel, withHost, withExtractPath, and withSilent in the Builder class to accept nullable parameters, ensuring flexibility in their usage. ([[1]](https://github.com/SeleniumHQ/selenium/pull/16001/files#diff-617a4c6d0ef39b1c4febbc83065a223bcd42281a33498df32b5e3cef6cb71677L157-R158), [[2]](https://github.com/SeleniumHQ/selenium/pull/16001/files#diff-617a4c6d0ef39b1c4febbc83065a223bcd42281a33498df32b5e3cef6cb71677L168-R169), [[3]](https://github.com/SeleniumHQ/selenium/pull/16001/files#diff-617a4c6d0ef39b1c4febbc83065a223bcd42281a33498df32b5e3cef6cb71677L179-R180), [[4]](https://github.com/SeleniumHQ/selenium/pull/16001/files#diff-617a4c6d0ef39b1c4febbc83065a223bcd42281a33498df32b5e3cef6cb71677L190-R191))
  • Adjusted createDriverService method: Added @Nullable annotations to parameters of the createDriverService method to account for cases where null values might be passed. ([java/src/org/openqa/selenium/ie/InternetExplorerDriverService.javaL247-R252](https://github.com/SeleniumHQ/selenium/pull/16001/files#diff-617a4c6d0ef39b1c4febbc83065a223bcd42281a33498df32b5e3cef6cb71677L247-R252))

General improvements:

  • Imported @Nullable annotation: Added the org.jspecify.annotations.Nullable import to enable the use of nullable annotations throughout the class. ([java/src/org/openqa/selenium/ie/InternetExplorerDriverService.javaR33](https://github.com/SeleniumHQ/selenium/pull/16001/files#diff-617a4c6d0ef39b1c4febbc83065a223bcd42281a33498df32b5e3cef6cb71677R33))

💡 Additional Considerations

🔄 Types of changes

  • Cleanup (formatting, renaming)

PR Type

Enhancement


Description

  • Add @Nullable annotations to InternetExplorerDriverService constructor parameters

  • Mark Builder class fields as nullable for type safety

  • Update method parameters with nullable annotations

  • Import JSpecify annotations for better null handling


Changes diagram

flowchart LR
  A["InternetExplorerDriverService"] --> B["Constructor Parameters"]
  A --> C["Builder Class"]
  B --> D["@Nullable File executable"]
  B --> E["@Nullable Duration timeout"]
  B --> F["@Nullable List<String> args"]
  B --> G["@Nullable Map<String, String> environment"]
  C --> H["@Nullable fields"]
  C --> I["@Nullable method parameters"]
Loading

Changes walkthrough 📝

Relevant files
Enhancement
InternetExplorerDriverService.java
Add nullable annotations for type safety                                 

java/src/org/openqa/selenium/ie/InternetExplorerDriverService.java

  • Import JSpecify @Nullable annotation
  • Add @Nullable to constructor parameters (executable, timeout, args,
    environment)
  • Mark Builder class fields as nullable (logLevel, host, extractPath,
    silent)
  • Update Builder method parameters with @Nullable annotations
  • +18/-13 

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • @selenium-ci selenium-ci added the C-java Java Bindings label Jul 5, 2025
    @qodo-merge-pro
    Copy link
    Contributor

    qodo-merge-pro bot commented Jul 5, 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

    Null Handling

    The constructor and builder methods now accept nullable parameters but there's no visible null checking or handling logic. This could lead to NullPointerExceptions if the parent class doesn't handle null values properly.

    public InternetExplorerDriverService(
        @Nullable File executable,
        int port,
        @Nullable Duration timeout,
        @Nullable List<String> args,
        @Nullable Map<String, String> environment)

    @qodo-merge-pro
    Copy link
    Contributor

    qodo-merge-pro bot commented Jul 5, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    General
    Remove redundant null initialization

    The @Nullable annotation is redundant when fields are explicitly initialized to
    null. The annotation should be placed before the type declaration for
    consistency with Java annotation conventions.

    java/src/org/openqa/selenium/ie/InternetExplorerDriverService.java [133-135]

    -private @Nullable String host = null;
    -private @Nullable File extractPath = null;
    -private @Nullable Boolean silent = null;
    +private @Nullable String host;
    +private @Nullable File extractPath;
    +private @Nullable Boolean silent;
    • Apply / Chat
    Suggestion importance[1-10]: 4

    __

    Why: The suggestion correctly identifies that explicitly initializing object fields to null is redundant, as it is the default behavior in Java, and removing it improves code conciseness.

    Low
    • Update

    @diemol diemol merged commit 4e1dc66 into SeleniumHQ:trunk Jul 7, 2025
    31 checks passed
    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

    3 participants