NullAway: NullAway doesn't recognize Guava Preconditions checks
I’m using Google Guava Preconditions to raise errors on null parameters. So basically, when I write something like:
Preconditions.checkArgument(item != null, "Unable to find an element with name '%s'.", name);
return item;
item
is null safe, but NullAway still raises an error.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 21 (1 by maintainers)
This shows up enough internally and asked about externally often enough that we should probably prioritize it above
lowpriority
. Most cases seem to be reducible toPreconditions.checkNotNull(...)
. But, as @ketkarameya 's example shows… some are a bit more involved.There are also cases like this, where there is no
null
check, but there is a call that implies null checking:Another flavor of this is scenario is-
Preconditions.checkArgument(item != null && someOtherCondition(item), "Unable to find an element with name '%s'.", name);
(Note I have a conjunction expression as the first argument).@jrepe no concrete plans to prioritize this. I would be open to accepting a PR if we could show it doesn’t impact overhead too much (and I don’t think it should).