You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The constructor and createDriverService method use List.copyOf() and Map.copyOf() on potentially null parameters without null checks, which could throw NullPointerException when null values are passed despite the @nullable annotations.
The constructor has a null check for executable parameter but no explicit null checks for other @nullable parameters like timeout, args, and environment, which may be used elsewhere in the constructor or class methods.
if (executable != null) {
this.executable = executable.getCanonicalPath();
}
The List.copyOf() and Map.copyOf() methods will throw NullPointerException if the arguments are null. Since args and environment are now marked as @Nullable, you should handle null values before copying.
Why: The suggestion correctly identifies that List.copyOf(args) and Map.copyOf(environment) will throw a NullPointerException if args or environment are null. Since the PR makes these parameters @Nullable, this change is critical to prevent a runtime crash.
High
General
Handle null log level appropriately
When logLevel is null, setting silent and verbose to false may not be the intended behavior. Consider handling the null case explicitly or documenting the expected behavior when null is passed.
Why: The suggestion correctly points out that unconditionally setting silent and verbose to false might be an unintended side effect when withLoglevel(null) is called. The proposed change improves the logic by only resetting these flags when a non-null logLevel is provided, making the method's behavior more robust and intuitive.
Low
Update
iampopovich
changed the title
Feat 14291/jspecify nullable annotation edge driver service
[java] Feat 14291/jspecify nullable annotation edge driver service
Jun 28, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
🔗 Related Issues
fixes #14291
💥 What does this PR do?
This pull request introduces changes to the
EdgeDriverServiceand its parent classDriverServiceto improve nullability handling by adding@Nullableannotations 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:@Nullableannotations to parameters in theEdgeDriverServiceconstructor, includingFile executable,Duration timeout,List<String> args, andMap<String, String> environment. This ensures better handling of optional values during service creation.Builderclass fields (e.g.,disableBuildCheck,logLevel,allowedListIps) with@Nullableannotations to explicitly mark them as optional.Builderclass, such aswithLoglevelandwithAllowedListIps, to include@Nullableannotations for their parameters, improving clarity about optional inputs. [1] [2] [3]createDriverServicemethod inEdgeDriverServiceto use@Nullableannotations for its parameters, aligning with the updated constructor.Nullability Enhancements in
DriverService:@Nullableannotations to theDriverServiceconstructor parameters (File executable,Duration timeout,List<String> args, andMap<String, String> environment) to propagate nullability handling to the parent class.💡 Additional Considerations
🔄 Types of changes
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
Changes walkthrough 📝
EdgeDriverService.java
Add @Nullable annotations for null safetyjava/src/org/openqa/selenium/edge/EdgeDriverService.java
timeout, args, environment)
logLevel, allowedListIps, etc.)
withAllowedListIps, withReadableTimestamp)
DriverService.java
Add @Nullable annotations to constructorjava/src/org/openqa/selenium/remote/service/DriverService.java
timeout, args, environment)
BUILD.bazel
Add jspecify dependencyjava/src/org/openqa/selenium/edge/BUILD.bazel