`if` statement on a boolean does not prevent a dereferenced nullable error
sdeleuze opened this issue · 1 comments
sdeleuze commented
Another frequent source of irrelevant errors in Spring Framework is this kind of code (with more complex conditions with additional &&
and/or reuse of the state of the boolean in other places):
@Nullable
protected ResourceLoader resourceLoader;
// ...
boolean resourceLoaderNotNull = (this.resourceLoader != null);
if (resourceLoaderNotNull) {
currentThread.setContextClassLoader(this.resourceLoader.getClassLoader());
}
Which trigger the following error:
error: [NullAway] dereferenced expression this.resourceLoader is @Nullable
currentThread.setContextClassLoader(this.resourceLoader.getClassLoader());
Would it be possible for NullAway to understand this use case?