null
is assigned to Optional
variable or returned from method returning
Optional
. It's recommended to use Optional.empty()
(or Optional.absent()
for Guava) to denote
an empty value.
Use checkbox below to report also comparisons like optional == null. While in rare cases (e.g. lazily initialized optional field) this might be correct, usually optional variable is never null, and probably optional.isPresent() was intended.
This inspection only reports if the language level of the project or module is 8 or higher
New in 2017.2