Skip to content

[java] specify nullability in package org.openqa.selenium.bidi.network - #17061

Merged
asolntsev merged 1 commit into
SeleniumHQ:trunkfrom
asolntsev:nullability-in-bidi-network
Feb 8, 2026
Merged

asolntsev merged 1 commit into
SeleniumHQ:trunkfrom
asolntsev:nullability-in-bidi-network

Conversation

@asolntsev

Copy link
Copy Markdown
Contributor

🔗 Related Issues

Part of #14291

💥 What does this PR do?

Marks the whole package org.openqa.selenium.bidi.network as non-nullable by default.

🔄 Types of changes

  • Cleanup (formatting, renaming)

@asolntsev asolntsev added this to the 4.41.0 milestone Feb 8, 2026
@asolntsev asolntsev self-assigned this Feb 8, 2026
@selenium-ci selenium-ci added C-java Java Bindings B-build Includes scripting, bazel and CI integrations B-devtools Includes everything BiDi or Chrome DevTools related labels Feb 8, 2026
@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Type

Enhancement


Description

  • Add nullability annotations to org.openqa.selenium.bidi.network package

  • Enforce non-null validation using Require utility methods

  • Add BiDi specification references as JavaDoc links

  • Optimize map creation using Map.of() and unmodifiableMap()

  • Extend Require.nonNegative() to support Long type


File Walkthrough

Relevant files
Enhancement
12 files
package-info.java
Create package-info with @NullMarked annotation                   
+21/-0   
AddInterceptParameters.java
Optimize map creation and add null validation                       
+4/-2     
AuthChallenge.java
Add null validation for scheme and realm fields                   
+2/-1     
BaseParameters.java
Add nullability annotations and comprehensive validation 
+23/-16 
BytesValue.java
Add nullability validation and optimize map creation         
+7/-9     
Cookie.java
Add nullability annotations and improve SameSite handling
+40/-27 
FetchTimingInfo.java
Add nullability validation for timing fields                         
+31/-26 
Header.java
Add null validation and optimize map creation                       
+6/-7     
Initiator.java
Make Type enum public and add null validation                       
+11/-11 
RequestData.java
Add new fields and nullability annotations                             
+54/-10 
ResponseData.java
Refactor optional fields to nullable and add validation   
+40/-34 
Require.java
Add nonNegative validation for Long type                                 
+8/-0     
Documentation
1 files
BeforeRequestSent.java
Add BiDi specification reference documentation                     
+4/-0     
Tests
1 files
RequireTest.java
Add tests for Long nonNegative validation                               
+9/-0     
Dependencies
1 files
BUILD.bazel
Add jspecify dependency for nullability annotations           
+1/-0     

@qodo-code-review

qodo-code-review Bot commented Feb 8, 2026 •

Copy link
Copy Markdown
Contributor

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🟢
🎫 #14291
🟢 Add JSpecify nullness annotations to Selenium framework code to indicate which
parameters/return values can be null.
Improve IDE/static analyzer visibility of nullability to help avoid NullPointerExceptions.

Improve interoperability with Kotlin by using explicit nullness annotations.
Codebase Duplication Compliance
⚪
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-code-review

qodo-code-review Bot commented Feb 8, 2026 •

Copy link
Copy Markdown
Contributor

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Fix incorrect JSON parsing logic

The method input.readMapElement() does not exist. Replace it with correct JSON
parsing logic to read the 'content' map and safely extract the 'size' value.

java/src/org/openqa/selenium/bidi/network/ResponseData.java [119-121]

 case "content":
-  contentSize = input.readMapElement("size");
+  Map<String, Object> content = input.read(new TypeToken<Map<String, Object>>() {}.getType());
+  if (content != null && content.get("size") instanceof Number) {
+    contentSize = ((Number) content.get("size")).longValue();
+  }
   break;
  • Apply / Chat
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies that input.readMapElement("size") is not a valid method in the JsonInput API, which would cause a compilation failure. It provides a robust and correct fix.

High
General
Validate bodySize non-negative

Add a validation check to ensure the bodySize field, if not null, is a
non-negative value, similar to the check for headersSize.

java/src/org/openqa/selenium/bidi/network/RequestData.java [59]

-this.bodySize = bodySize;
+this.bodySize = bodySize != null
+    ? Require.nonNegative("bodySize", bodySize)
+    : null;
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly proposes adding a non-negative check for bodySize, which is consistent with how headersSize is handled in the same constructor and improves data integrity.

Medium
Return immutable list values

In the toMap method, wrap the phases and urlPatterns lists with List.copyOf to
ensure the returned map contains immutable collections.

java/src/org/openqa/selenium/bidi/network/AddInterceptParameters.java [63-66]

-map.put("phases", phases);
+map.put("phases", List.copyOf(phases));
 if (!urlPatterns.isEmpty()) {
-  map.put("urlPatterns", urlPatterns);
+  map.put("urlPatterns", List.copyOf(urlPatterns));
 }
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion improves immutability by making defensive copies of the lists before they are put into the unmodifiable map, which is a good practice to prevent modification of the class's internal state.

Low
Serialize enum as string

When serializing the sameSite field, explicitly convert the enum to its string
representation by calling sameSite.toString().

java/src/org/openqa/selenium/bidi/network/Cookie.java [197]

-if (sameSite != null) map.put("sameSite", sameSite);
+if (sameSite != null) map.put("sameSite", sameSite.toString());
  • Apply / Chat
Suggestion importance[1-10]: 5

__

Why: The suggestion correctly points out that an enum should be converted to a string for serialization. While map.put("sameSite", sameSite) might work implicitly, explicitly calling .toString() is clearer and safer.

Low
  • Update

@asolntsev
asolntsev force-pushed the nullability-in-bidi-network branch from ad5940d to 487a58e Compare February 8, 2026 14:44
@asolntsev asolntsev changed the title specify nullability in package org.openqa.selenium.bidi.network [java] specify nullability in package org.openqa.selenium.bidi.network Feb 8, 2026
@asolntsev
asolntsev merged commit 678f21c into SeleniumHQ:trunk Feb 8, 2026
44 checks passed
@asolntsev
asolntsev deleted the nullability-in-bidi-network branch February 8, 2026 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

B-build Includes scripting, bazel and CI integrations B-devtools Includes everything BiDi or Chrome DevTools related C-java Java Bindings Review effort 3/5

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants