I think I may have found a false positive. On SonarCloud, S4449 raises an issue for the following code:
String foo = map.get(key); return Optional.fromNullable(foo); // FP
Annotate the parameter with @javax.annotation.Nullable in method ‘fromNullable’ declaration, or make sure that null can not be passed as argument.
However, this seems to be already the case:
com.google.common.baseis annotated with
- The parameter of
Optional.fromNullable()is annotated with
I’m not sure whether these two annotations from two different packages are supposed to be mixed, though. Is this an error in SonarJava or in Guava?
The exact same situation exists with
com.google.common.util.concurrent.SettableFuture. Here are the SonarCloud issues in our project for both
We use Guava version
25.1-jre, but the relevant code is unchanged in