Skip to content

mark wait.until as non-nullable#17007

Merged
asolntsev merged 1 commit intoSeleniumHQ:trunkfrom
asolntsev:return-nonnullable-from-wait
Jan 27, 2026
Merged

mark wait.until as non-nullable#17007
asolntsev merged 1 commit intoSeleniumHQ:trunkfrom
asolntsev:return-nonnullable-from-wait

Conversation

@asolntsev
Copy link
Contributor

@asolntsev asolntsev commented Jan 26, 2026

They always return true/false, WebDriver or WebElement. They never return null.

🔗 Related Issues

Fixes #16970

Adds @NullMarked annotation to Wait, FluentWait etc.
@TWiStErRob

🔄 Types of changes

  • Bug fix (backwards compatible)

@asolntsev asolntsev added this to the 4.41.0 milestone Jan 26, 2026
@asolntsev asolntsev self-assigned this Jan 26, 2026
@selenium-ci selenium-ci added C-java Java Bindings B-build Includes scripting, bazel and CI integrations B-support Issue or PR related to support classes labels Jan 26, 2026
@qodo-code-review
Copy link
Contributor

User description

They always return true/false, WebDriver or WebElement. They never return null.

🔗 Related Issues

Fixes #16970

Adds @NullMarked annotation to Wait, FluentWait etc.

🔄 Types of changes

  • Bug fix (backwards compatible)

PR Type

Enhancement


Description

  • Add @NullMarked annotation to support.ui package for null-safety

  • Mark Wait.until() return values as non-nullable

  • Add @Nullable annotations to exception causes and message suppliers

  • Add @NonNull annotations to getCapabilities() methods

  • Enforce non-null validation in FluentWait.withMessage() methods


Diagram Walkthrough

flowchart LR
  A["FluentWait/Wait API"] -->|Add @NullMarked| B["Package-level null safety"]
  A -->|Mark until() return| C["Non-nullable return values"]
  A -->|Add @Nullable| D["Exception causes & suppliers"]
  E["getCapabilities() methods"] -->|Add @NonNull| F["Non-nullable capabilities"]
  G["withMessage() methods"] -->|Add validation| H["Enforce non-null inputs"]
Loading

File Walkthrough

Relevant files
Enhancement
9 files
package-info.java
Add @NullMarked annotation to package                                       
+21/-0   
FluentWait.java
Mark until() return and add null validations                         
+8/-6     
Wait.java
Mark until() return as non-nullable                                           
WebDriverWait.java
Add @Nullable annotation to timeout exception                       
+2/-1     
ExpectedCondition.java
Remove @NullMarked, update documentation                                 
+1/-3     
ExpectedConditions.java
Remove @NullMarked class annotation                                           
+0/-2     
TimeoutException.java
Add @Nullable annotation to cause parameter                           
+3/-1     
FirefoxDriver.java
Mark getCapabilities() return as non-nullable                       
+2/-0     
RemoteWebDriver.java
Mark getCapabilities() return as non-nullable                       
+2/-0     
Tests
3 files
AugmenterTest.java
Update test driver to use constructor injection                   
+7/-4     
FluentWaitTest.java
Add @Nullable annotation to test method                                   
+3/-1     
package-info.java
Add @NullMarked annotation to test package                             
+21/-0   
Documentation
1 files
QuotesTest.java
Fix javadoc formatting in test comment                                     
+2/-2     
Configuration changes
1 files
BUILD.bazel
Add jspecify dependency to test suite                                       
+1/-0     

@qodo-code-review
Copy link
Contributor

qodo-code-review bot commented Jan 26, 2026

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
🎫 No ticket provided
  • Create ticket/issue
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
Copy link
Contributor

qodo-code-review bot commented Jan 26, 2026

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Align method parameter with field type

In FluentWait.withMessage, change the messageSupplier parameter type from
Supplier to Supplier<@Nullable String> to match the corresponding field's type
and allow suppliers that can return null.

java/src/org/openqa/selenium/support/ui/FluentWait.java [132-135]

-public FluentWait<T> withMessage(Supplier<String> messageSupplier) {
+public FluentWait<T> withMessage(Supplier<@Nullable String> messageSupplier) {
   this.messageSupplier = Require.nonNull("Message supplier", messageSupplier);
   return this;
 }
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: This is a good suggestion that improves API consistency by aligning the parameter type of withMessage with the messageSupplier field type, which correctly allows suppliers that can return null.

Low
  • Update

@SeleniumHQ SeleniumHQ deleted a comment from selenium-ci Jan 26, 2026
@asolntsev asolntsev force-pushed the return-nonnullable-from-wait branch from 50d42d7 to 8375807 Compare January 26, 2026 21:46
They always return true/false, WebDriver or Webelement. They never return null.
@asolntsev asolntsev force-pushed the return-nonnullable-from-wait branch from 8375807 to e89e912 Compare January 26, 2026 22:22
@asolntsev asolntsev merged commit 658c69f into SeleniumHQ:trunk Jan 27, 2026
82 of 86 checks passed
@asolntsev asolntsev deleted the return-nonnullable-from-wait branch January 27, 2026 10:12
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-support Issue or PR related to support classes C-java Java Bindings Review effort 2/5

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[🐛 Bug]: Java Wait/FluentWait.until missing non-null return type

2 participants