Hi all!
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.base
is annotated withjavax.annotation.ParametersAreNonnullByDefault
- The parameter of
Optional.fromNullable()
is annotated withorg.checkerframework.checker.nullness.qual.Nullable
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 Optional
and SettableFuture
.
We use Guava version 25.1-jre
, but the relevant code is unchanged in 26.0
.
Best regards,
Jens