Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Skip FluentFutureHandler in JSpecify mode - #2066

Merged
msridhar merged 1 commit into
apache:masterfrom
vlsi:claude/fluent-future-handler-jspecify
Oct 24, 2026
Merged

msridhar merged 1 commit into
apache:masterfrom
vlsi:claude/fluent-future-handler-jspecify

Conversation

@vlsi

@vlsi vlsi commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

FluentFutureHandler treats the return of a Guava Function or AsyncFunction lambda passed to transform, transformAsync, catching, or catchingAsync of Futures or FluentFuture as nullable. Its Javadoc calls it a workaround for missing generics support. In JSpecify mode, generic method inference now covers these calls: ListenableFuture<@Nullable String> r = Futures.transform(in, x -> null, e) is accepted without the handler, and with a non-null target the inference reports type variable O constrained to be both @NonNull and @Nullable with or without it. In that mode the handler only hid the returning @Nullable expression error on a return null inside a block lambda. For transformAsync and catchingAsync that error is real, because an AsyncFunction returns the future itself.

Register the handler only outside JSpecify mode, the same split #2040 makes for the Guava functional-interface library models.

User-visible:
In JSpecify mode, return null in a block lambda passed to these methods is reported as returning @Nullable expression from method with @NonNull return type when the inferred result type is non-null, and always for transformAsync and catchingAsync.
In JSpecify mode, the ExtraFuturesClasses option has no effect: a lambda passed to a configured class gets its return nullability from that class's type parameters.
Not changed: outside JSpecify mode, the handler and ExtraFuturesClasses work as before.

The new JSpecify-mode tests in NullAwayGuavaParametricNullnessTests fail with the handler registered: every returning @Nullable expression expectation goes unseen. :guava-recent-unit-tests:test, :nullaway:test, :nullaway:buildWithNullAway pass; :nullaway:pitestDiff kills the one mutant on the changed lines.

Assisted-by: Claude Code (claude-opus-5-5)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • In JSpecify mode, nullness analysis now handles null-returning lambdas passed to Guava future APIs according to whether the result type allows null.
    • The default FluentFuture handling differs in JSpecify mode, where generic method inference determines whether a lambda may return null.
  • Documentation
    • Clarified that configuring extra future wrapper classes has no effect in JSpecify mode.

FluentFutureHandler treats the return of a Guava Function or AsyncFunction lambda passed to transform, transformAsync, catching, or catchingAsync of Futures or FluentFuture as nullable. Its Javadoc calls it a workaround for missing generics support. In JSpecify mode, generic method inference now covers these calls: `ListenableFuture<@nullable String> r = Futures.transform(in, x -> null, e)` is accepted without the handler, and with a non-null target the inference reports `type variable O constrained to be both @nonnull and @Nullable` with or without it. In that mode the handler only hid the `returning @nullable expression` error on a `return null` inside a block lambda. For transformAsync and catchingAsync that error is real, because an AsyncFunction returns the future itself.

Register the handler only outside JSpecify mode, the same split apache#2040 makes for the Guava functional-interface library models.

User-visible:
In JSpecify mode, `return null` in a block lambda passed to these methods is reported as `returning @nullable expression from method with @nonnull return type` when the inferred result type is non-null, and always for transformAsync and catchingAsync.
In JSpecify mode, the ExtraFuturesClasses option has no effect: a lambda passed to a configured class gets its return nullability from that class's type parameters.
Not changed: outside JSpecify mode, the handler and ExtraFuturesClasses work as before.

Assisted-by: Claude Code (claude-opus-5-5)
@coderabbitai

coderabbitai Bot commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between edc316c and 34b3bd1.

Files selected for processing: 4
  • guava-recent-unit-tests/src/test/java/com/uber/nullaway/guava/NullAwayGuavaParametricNullnessTests.java
  • nullaway/src/main/java/com/uber/nullaway/Config.java
  • nullaway/src/main/java/com/uber/nullaway/handlers/Handlers.java
  • nullaway/src/main/java/com/uber/nullaway/handlers/temporary/FluentFutureHandler.java

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

Walkthrough

In JSpecify mode, the default handler chain no longer registers FluentFutureHandler. New tests check null-returning lambdas for Guava future APIs and configured extra future classes, including expected diagnostics for non-null results or future returns. Config documentation states that extra future classes have no effect in JSpecify mode.

Possibly related issues

Possibly related PRs

  • uber/NullAway#2052: Updates FluentFutureHandler lambda handling, which this PR limits to non-JSpecify mode.
  • uber/NullAway#2040: Separates Guava functional-interface models by nullness mode, a related mode distinction.

Suggested reviewers: msridhar

Priority: Normal

Change: Bug fix

Merge Risk: Minimal · up to 34b3b

The change is ready to merge after normal checks; no concrete regression remains identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: skipping FluentFutureHandler in JSpecify mode.
Description check Passed The description directly explains the handler change, its JSpecify rationale, affected behavior, tests, and preserved non-JSpecify behavior.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.21%. Comparing base (edc316c) to head (34b3bd1).

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #2066   +/-   ##
=========================================
  Coverage     89.20%   89.21%           
  Complexity       38       38           
=========================================
  Files           119      119           
  Lines         12771    12772    +1     
  Branches       2589     2590    +1     
=========================================
+ Hits          11393    11394    +1     
  Misses          623      623           
  Partials        755      755           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@msridhar
msridhar added this pull request to the merge queue Oct 24, 2026
Merged via the queue into apache:master with commit 824e5d1 Oct 24, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants