I have a function that could return a null value. So I used JetBrains annotation and put a @Nullable
annotation on top of the function.
@Nullable
public static ConnectionManager getConnectionManager() {
return connectionManager;
}
Then, I runned a Lint inspection. I found 4 places when I use this function and I wasn't doing any null check.
Before:
Service.getConnectionManager().onAssetInfoChanged();
After:
if(Service.getConnectionManager() != null) {
Service.getConnectionManager().onAssetInfoChanged();
}
Then I run the Lint inspection again. To my big surprise, I'm still getting:
Method invocation '
Service.getConnectionManager().onAssetInfoChanged()
' at line 308 may produce 'java.lang.NullPointerException
'.
What am I doing wrong? Is this a bug in the Lint inspector?