Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if (Foo.this.bar != null) in nested class not properly analyzed #936

Closed
sdeleuze opened this issue Mar 22, 2024 · 1 comment · Fixed by #937
Closed

if (Foo.this.bar != null) in nested class not properly analyzed #936

sdeleuze opened this issue Mar 22, 2024 · 1 comment · Fixed by #937
Assignees

Comments

@sdeleuze
Copy link

In Spring, we have code like:

if (DefaultRestClient.this.initializers != null) {
    DefaultRestClient.this.initializers.forEach(initializer -> initializer.initialize(request));
}

Which generates the following error:

/Users/sdeleuze/workspace/spring-framework/spring-web/src/main/java/org/springframework/web/client/DefaultRestClient.java:539: error: [NullAway] dereferenced expression DefaultRestClient.this.initializers is @Nullable
                                DefaultRestClient.this.initializers.forEach(initializer -> initializer.initialize(request));

I would expect such construct not triggering an error.

@msridhar
Copy link
Collaborator

Thanks for the report! I've put up a PR #937 to fix this case.

msridhar added a commit that referenced this issue Mar 22, 2024
Fixes #936 

We add limited tracking of such access paths, to handle null checks on
fields from an enclosing class of a nested class.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants