Since 1.8 Java has a type Optional which might or might not contain a not-null value. Best practice is to never use null where an Optional should be used (e.g. if a method's return type is Optional it shouldn't return null) and always call isPresent() before calling get() (similar to the annotation CheckForNull).
It would be nice to have FinBugs-rules which enforce this practice.
Log in to post a comment.