uber / uber/NullAway

Missing check for library models for lambdas with an expression body

Open
#910 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
4.1k
Forks
370
Avg merge
1d 13h
Merged PRs (30d)
68

Description

In our handling of lambdas, we immediately bail out of all checking if the corresponding functional interface method is unannotated:

https://github.com/uber/NullAway/blob/084bd96ff473252715229fc41e02ac11f6f2bfd1/nullaway/src/main/java/com/uber/nullaway/NullAway.java#L957-L959

But, this skips a check that is later performed for return types, where we allow library models to override return type nullability:

https://github.com/uber/NullAway/blob/084bd96ff473252715229fc41e02ac11f6f2bfd1/nullaway/src/main/java/com/uber/nullaway/NullAway.java#L875-L877

In particular, we model Guava Functions as having a @NonNull return, but if you write (x) -> null and pass it as a Guava Function currently NullAway does not report an error. In contrast, writing (x) -> { return null; } yields an error. This should be relatively easy to fix, but it will lead to new errors when users do a NullAway update.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in nullaway/src/main/java/com/uber/nullaway/NullAway.java around lines 957-959 and compare the lambda handling with lines 875-877, where library models can override return nullability. Reproduce the Guava Function cases using expression and block lambda bodies. Done means an expression-bodied lambda returning null is checked consistently with the block-bodied form, with regression coverage added where appropriate.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.