-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
If in a method that returns Optional, a lambda expression returns something else than Optional, that lambda gives a false positive warning of not returning Optional.
public Optional<Object> getSomeOptional() {
Function<String, String> f = (String s) -> {
return "text";
};
return Optional.empty();
}
In the above example, the return "text"
correctly returns a String, but Netbeans still gives the following warning:
Convert to Optional.ofNullable()/Optional.of(). The return value should be an Optional instance for a method with a return value java.util.Optional.
The warning probably thinks return "text"
is a return statement of the method, even though it really is a return statement of the lambda.
t-gergely
Metadata
Metadata
Assignees
Labels
No labels