Skip to content

Consistent null check on injection points for pre-existing singleton beans #34952

New issue

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

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

Already on GitHub? # to your account

Closed
jhoeller opened this issue May 27, 2025 · 0 comments
Closed
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Milestone

Comments

@jhoeller
Copy link
Contributor

In the course of #34929, it turned out that the common resolution code path does not perform a proper null bean check in case of a pre-existing singleton, due to a mismatch between the singleton retrieval optimization (which immediately turns a NullBean into null) and the instance resolution step (which still checks for NullBean). In #34929, we were bound to restore backwards compatibility for the shortcut code path even if this actually revealed a bug.

As a side note, this has not been reported by NullAway due to the unspecified nullability of Map.get access that we use internally. In any case, this needs to be addressed for 7.0 where it fits with the general JSpecify nullability revision.

@jhoeller jhoeller added this to the 7.0.0-M6 milestone May 27, 2025
@jhoeller jhoeller self-assigned this May 27, 2025
@jhoeller jhoeller added type: bug A general bug in: core Issues in core modules (aop, beans, core, context, expression) labels May 27, 2025
sdeleuze added a commit to sdeleuze/spring-framework that referenced this issue May 28, 2025
The KotlinDelegate#isNullable invocation is unnecessary since this check
is already done by the Nullness#forField one introduced by
b5d153f.

See spring-projectsgh-34952
See spring-projectsgh-34261
sbrannen added a commit that referenced this issue Jun 7, 2025
The hasNullableAnnotation() method was made obsolete in commit
b5d153f.

See gh-34952
See gh-34261
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

1 participant