uber / NullAway

A tool to help eliminate NullPointerExceptions (NPEs) in your Java code with low build-time overhead
MIT License
3.63k stars 293 forks source link

Method references of nullable instances are not detected #919

Closed laukerta closed 7 months ago

laukerta commented 7 months ago

When I write

public static void doSomething(@Nullable String text) {
    return Set.of("a", "b", "c").stream().anyMatch(text::contains);
}

I receive no complains from NullAway although invoking the method reference will lead to a NPE.

If I replace the method reference by a lambda:

public static void doSomething(@Nullable String text) {
    return Set.of("a", "b", "c").stream().anyMatch(s -> text.contains(s));
}

I receive (and I expect this):

java: [NullAway] dereferenced expression text is @Nullable
    (see http://t.uber.com/nullaway )

I am using version 0.10.23.

msridhar commented 7 months ago

Great find! I will work on this as soon as I can and get a fix up.