Repository navigation
Introduce FluentFutureHandler as a workaround for Guava Futures/FluentFuture - #771
Merged
Merged
Conversation
Pull Request Test Coverage Report for Build #1105
💛 - Coveralls |
msridhar
approved these changes
Jun 21, 2023
msridhar
left a comment
Contributor
There was a problem hiding this comment.
One typo fix and this should be good to land. Approving assuming the typo will be fixed :-)
This is really a case where we need much deeper generics support, and we are just not there yet. Hopefully we can get closer soon.
I would ideally like to do perf benchmarking here, and I can't wait until #770 lands to make it easy! For now, based on reading the code I don't think it should have much perf impact, so we can go ahead and land.
| "catching", "catchingAsync", "transform", "transformAsync" | ||
| }; | ||
|
|
||
| private static boolean isGuavaFunctionDotAppy(Symbol.MethodSymbol methodSymbol) { |
Contributor
There was a problem hiding this comment.
Suggested change
| private static boolean isGuavaFunctionDotAppy(Symbol.MethodSymbol methodSymbol) { | |
| private static boolean isGuavaFunctionDotApply(Symbol.MethodSymbol methodSymbol) { |
…ullable T> without generics support
lazaroclapp
force-pushed
the
lazaro_fluent_future_function_hack_handler
branch
from
June 21, 2023 22:26
96621fd to
ad67028
Compare
msridhar
added a commit
to msridhar/NullAway
that referenced
this pull request
Jul 18, 2023
…es/FluentFuture (apache#771)" This reverts commit 37f4bb8.
msridhar
added a commit
to msridhar/NullAway
that referenced
this pull request
Jul 18, 2023
…es/FluentFuture (apache#771)" This reverts commit 37f4bb8.
msridhar
added a commit
to msridhar/NullAway
that referenced
this pull request
Jul 19, 2023
…es/FluentFuture (apache#771)" This reverts commit 37f4bb8.
msridhar
added a commit
to msridhar/NullAway
that referenced
this pull request
Jul 19, 2023
…es/FluentFuture (apache#771)" This reverts commit 37f4bb8.
msridhar
added a commit
to msridhar/NullAway
that referenced
this pull request
Jul 19, 2023
…es/FluentFuture (apache#771)" This reverts commit 37f4bb8.
msridhar
added a commit
that referenced
this pull request
Feb 15, 2024
This allows for a list of classes to be passed in via a command-line argument `-XepOpt:NullAway:ExtraFuturesClasses`. Such classes will be treated equivalently to built-in Guava Futures classes via the `FluentFutureHandler`. This is a follow-up to #771.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
We need this due to our incomplete support for generics, and the fact that #765 fixes a previous
false negative which would cause our
@NonNullmodel for Guava'sFunctionto be ignoredwhen determining the correct overriding of the functional interface by a lambda.
After the fix, however, code such as:
will fail with an error about
Function::applyhaving a@NonNullresult. Where nullability shouldactually depend on the parameter
Tof theListenableFuture<T>in question.Unfortunately, usage of this futures API is common internally for us, and our generics support is far
from fully supporting this in a sound manner, so this diff introduces a (hopefully temporary) workaround,
in the form of handler for the Futures/FluentFuture Guava APIs:
This works by special casing the return nullability of
com.google.common.base.Functionandcom.google.common.util.concurrent.AsyncFunctionto be e.g.Function<@Nullable T>wheneverthese functional interfaces are implemented as a lambda expression passed to a list of specific
methods of
com.google.common.util.concurrent.FluentFutureorcom.google.common.util.concurrent.Futures. This is unsound, but permits the code example above topass NullAway checking, while strictly reducing the safety hole of NullAway versions prior to PR #765.