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
The PR fails to mark the package as non-nullable because it omits the @NullMarked annotation in a package-info.java file. It incorrectly uses runtime null checks instead of enabling the static analysis described in the PR's goal.
// In a new file: java/src/org/openqa/selenium/bidi/log/package-info.java@NullMarkedpackageorg.openqa.selenium.bidi.log;
importorg.jspecify.annotations.NullMarked;
// ---// With the @NullMarked annotation at the package level,// static analysis tools will enforce non-null contracts for the// entire package's public API, achieving the PR's stated goal.// The runtime checks in `fromJson` methods might still be useful for// defensive programming against malformed input, but they do not// replace the need for static analysis annotations.
Suggestion importance[1-10]: 10
__
Why: The suggestion correctly identifies a critical flaw where the PR's implementation (runtime checks) completely contradicts its stated goal and the related ticket's objective (static analysis via @NullMarked annotation).
High
Possible issue
Validate log entry type in constructor
In the JavascriptLogEntry constructor, validate that the type parameter is equal to "javascript" to ensure compliance with the WebDriver BiDi specification.
Why: The PR refactoring removed the hardcoded "javascript" type, but the new code in fromJson now passes the type from the JSON payload to the constructor without validation. This suggestion correctly points out that the type should be validated to be "javascript" to conform to the BiDi spec, fixing a potential issue introduced by the PR.
Medium
Add null checks for constructor parameters
Add Require.nonNull() checks for the scriptUrl and function parameters in the StackFrame constructor to ensure they are not null.
Why: This suggestion correctly identifies that the StackFrame constructor lacks null checks for scriptUrl and function. While the fromJson method in the PR does perform these checks before calling the constructor, adding them to the constructor itself is a good practice for ensuring object invariants and making the class more robust against other instantiation paths.
Medium
General
Make args list immutable
In the ConsoleLogEntry constructor, wrap the args list parameter with List.copyOf() before assigning it to the field to ensure immutability.
[To ensure code accuracy, apply this suggestion manually]
Suggestion importance[1-10]: 7
__
Why: This is a valid suggestion that improves the robustness of the ConsoleLogEntry class by making it immutable. Storing a defensive copy of the args list prevents external modifications to the object's internal state, which is a good practice for value objects.
Medium
Make callFrames immutable
In the StackTrace constructor, wrap the callFrames list parameter with List.copyOf() to ensure the internal list is immutable.
Why: This is a valid suggestion that improves the robustness of the StackTrace class by making it immutable. Creating a defensive copy of the callFrames list prevents external modifications to the object's internal state, which is a good practice for value objects.
Medium
Improve error message for missing property
In StackTrace.fromJson, replace input.readNonNull() with input.read() followed by a Require.nonNull() check for the callFrames property to provide a more informative error message if it is missing.
public static StackTrace fromJson(JsonInput input) {
-- List<StackFrame> callFrames = emptyList();+ List<StackFrame> callFrames = null;
input.beginObject();
while (input.hasNext()) {
if ("callFrames".equals(input.nextName())) {
- callFrames = input.readNonNull(new TypeToken<List<StackFrame>>() {}.getType());+ callFrames = input.read(new TypeToken<List<StackFrame>>() {}.getType());
} else {
input.skipValue();
}
}
input.endObject();
- return new StackTrace(callFrames);+ return new StackTrace(Require.nonNull("Call frames for stack trace", callFrames));
}
Apply / Chat
Suggestion importance[1-10]: 6
__
Why: The suggestion provides a valid way to improve error messaging by using Require.nonNull instead of readNonNull. This aligns with the pattern used elsewhere in the PR for other required fields, leading to more consistent and informative error handling.
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 package
org.openqa.selenium.bidi.logas non-nullable by default.🔄 Types of changes