Skip to content

Lambda argument to Flux#mapNotNull with null return value flagged as invalid #1522

Closed

Description

@Stephan202

This issue tracks the topic discussed over at PicnicSupermarket/error-prone-support#1969 (comment).

In a nutshell, with NullAway 0.13.2:

  • Now that Project Reactor adopted JSpecify, the signature of Flux#mapNotNull is:
    public final <V> Flux<V> mapNotNull(Function <? super T, ? extends @Nullable V> mapper)
  • However, when NullAway analyzes code such as the following in JSpecify mode, it flags "returning @Nullable expression from method with @NonNull return type":
    Flux<T> after(Flux<Optional<T>> flux) {
      return flux.mapNotNull(x -> x.orElse(null));
    }

Full reproduction steps:

git clone git@github.com:PicnicSupermarket/error-prone-support.git
cd error-prone-support
git checkout e9b11746ea51f477ae5a4f628362372b5efaa608
sed -i '/@SuppressWarnings.*NullAway/d' -- error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ReactorRules.java
mvn compile

Activity

  1. msridhar commented on Apr 21, 2026

    @msridhar
    Contributor

    Thanks, @Stephan202. Once we add more wildcard support and can handle cases like #1462 we will check in on this one again to see that it's supported.

  2. added a commit that references this issue on May 3, 2026
  3. added a commit that references this issue on May 25, 2026
    9e7cfb2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions