Skip to content

StackOverflowError on mongoTemplate.find when entity have a generic type #2799

Open
@felipeissa

Description

@felipeissa

I'm currently upgrading to spring-boot 2.7.9 and I'm getting the following error when I do a find:

java.lang.StackOverflowError
	at org.springframework.data.util.TypeDiscoverer.createInfo(TypeDiscoverer.java:106)
	at org.springframework.data.util.ParentTypeAwareTypeInformation.createInfo(ParentTypeAwareTypeInformation.java:71)
	at org.springframework.data.util.TypeVariableTypeInformation.lambda$new$0(TypeVariableTypeInformation.java:55)
	at org.springframework.data.util.Lazy.getNullable(Lazy.java:231)
	at org.springframework.data.util.Lazy.get(Lazy.java:115)
	at org.springframework.data.util.TypeVariableTypeInformation.getTypeArguments(TypeVariableTypeInformation.java:65)
	at org.springframework.data.util.TypeVariableTypeInformation.lambda$new$0(TypeVariableTypeInformation.java:55)
	at org.springframework.data.util.Lazy.getNullable(Lazy.java:231)
	at org.springframework.data.util.Lazy.get(Lazy.java:115)
	at org.springframework.data.util.TypeVariableTypeInformation.getTypeArguments(TypeVariableTypeInformation.java:65)
	at org.springframework.data.util.TypeVariableTypeInformation.lambda$new$0(TypeVariableTypeInformation.java:55)
	at org.springframework.data.util.Lazy.getNullable(Lazy.java:231)
	at org.springframework.data.util.Lazy.get(Lazy.java:115)
	at org.springframework.data.util.TypeVariableTypeInformation.getTypeArguments(TypeVariableTypeInformation.java:65)
	at org.springframework.data.util.TypeVariableTypeInformation.lambda$new$0(TypeVariableTypeInformation.java:55)
	at org.springframework.data.util.Lazy.getNullable(Lazy.java:231)
	at org.springframework.data.util.Lazy.get(Lazy.java:115)

This happens only when the entity I'm trying to read have a generic field on it, which I'm not passing to the 'find' method on mongoTemplate.

A working example of this problem can be seen on this repo: https://github.com/felipeissa/mongo-generic-overflow. Only configure the database and run it and the problem will appear.

Spring version: 2.7.9
Jdk Version: 11.0.17
Os: Windows 11

Metadata

Metadata

Labels

type: regressionA regression from a previous release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions