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

Types with self-bounding generics cause infinite recursion in ResolvableType #32282

Closed
kilink opened this issue Feb 16, 2024 · 1 comment
Closed
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: task A general task
Milestone

Comments

@kilink
Copy link
Contributor

kilink commented Feb 16, 2024

The change in e788aeb has surfaced an issue with handling of types with self-bounding generics in ResolvableType. I already commented on the original PR (#30079), just capturing it here for visibility. The following test cases will triggers infinite recursion / stack overflow:

enum Foo { BAR }
ResolvableType.forType(Foo.class.getGenericSuperclass()).hasUnresolvableGenerics();
// or
ResolvableType.forClassWithGenerics(Enum.class, Foo.class).hasUnresolvableGenerics();
class Foo<T extends Foo<T>> {}
class Bar extends Foo<Bar> {}

ResolvableType.forInstance(new Bar()).hasUnresolvableGenerics();

This happens during app start up in a typical Spring Boot app, due to events such as AvailabilityChangeEvent<LivenessState> being emitted.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 16, 2024
@snicoll snicoll added type: task A general task and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Feb 16, 2024
@snicoll snicoll added this to the 6.2.0-M1 milestone Feb 16, 2024
@snicoll snicoll added the in: core Issues in core modules (aop, beans, core, context, expression) label Feb 16, 2024
@snicoll
Copy link
Member

snicoll commented Feb 16, 2024

Moving to a task as the fix was never released and we can't really reopen the PR. Thanks very much for reporting @kilink!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: task A general task
Projects
None yet
Development

No branches or pull requests

4 participants