spring-projects / spring-projects/spring-data-commons
StackOverflowError on mongoTemplate.find when entity have a generic type
Open
@christophstrobl is already working on this.
Since Mar 27, 2023.
type: regression
- Dominant language
- Java
- Stars
- 838
- Forks
- 730
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.