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
{{ message }}
Repository navigation
[java] specify nullability in package org.openqa.selenium.bidi.script - #17062
asolntsev
changed the title
specify nullability in package org.openqa.selenium.bidi.script
[java] specify nullability in package org.openqa.selenium.bidi.scriptFeb 8, 2026
The PR alters several findByName methods to throw an IllegalArgumentException instead of returning null for unknown values. This is a breaking semantic change that should be verified as intentional and consistent with the library's error handling strategy.
publicstaticTypefindByName(Stringname) {
for (Typetype : values()) {
if (type.toString().equalsIgnoreCase(name)) {
returntype;
}
}
thrownewIllegalArgumentException("Unsupported value type: " + name);
}
Solution Walkthrough:
Before:
// In PermissionState.javapublicstatic@NullablePermissionStatefindByName(Stringname) {
PermissionStateresult = null;
for (PermissionStatestate : values()) {
if (state.toString().equalsIgnoreCase(name)) {
result = state;
break;
}
}
returnresult;
}
After:
// In PermissionState.javapublicstaticPermissionStatefindByName(Stringname) {
for (PermissionStatestate : values()) {
if (state.toString().equalsIgnoreCase(name)) {
returnstate;
}
}
thrownewIllegalArgumentException("Unsupported permission state: " + name);
}
Suggestion importance[1-10]: 8
__
Why: The suggestion correctly identifies a significant, potentially breaking API change where multiple findByName methods now throw exceptions instead of returning null, a change not highlighted in the PR description.
Medium
Possible issue
Handle null arguments to prevent NullPointerException
Add a null check at the start of the getArgument method to handle null inputs and prevent a potential NullPointerException.
Why: This suggestion correctly identifies a NullPointerException when arg is null and provides a proper fix by handling the null case explicitly, which improves the robustness of the getArgument method.
Medium
Prevent NullPointerException on missing JSON fields
In the fromJson method, wrap nodeType and childNodeCount with Require.nonNull before passing them to Require.nonNegative to prevent a NullPointerException if the fields are missing from the JSON.
[To ensure code accuracy, apply this suggestion manually]
Suggestion importance[1-10]: 8
__
Why: The suggestion correctly identifies a potential NullPointerException if nodeType or childNodeCount are missing from the JSON input, due to auto-unboxing a nullLong. The proposed fix of wrapping the call with Require.nonNull is accurate and improves the method's robustness.
Medium
General
Support all numeric types
Refactor the numberToLocalValue method to simplify numeric type handling. Consolidate integer-like types by using arg.longValue() and handle floating-point and BigInteger types separately.
Why: The suggestion correctly simplifies the logic in numberToLocalValue by removing the explicit checks for Integer and Long and relying on the longValue() method of Number. This makes the code cleaner and correctly handles other integer-like Number types such as Byte and Short.
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.
🔗 Related Issues
Part of #14291
💥 What does this PR do?
Marks the whole packages
org.openqa.selenium.bidi.scriptandorg.openqa.selenium.bidi.permissionsas non-nullable by default.🔄 Types of changes