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

StackOverflowError at AbstractJackson2HttpMessageConverter.resolveVariable [SPR-14520] #19089

Closed
spring-projects-issues opened this issue Jul 28, 2016 · 6 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jul 28, 2016

Gerasimov Gennady opened SPR-14520 and commented

Jackson 2.8.1
Spring 4.3.1.RELEASE

We have a complex hierarchy of classes like

public class Api
        extends BaseApi
        implements CrudApi<ObjectA, ObjectB, Long> {
}

where

public interface CrudApi<S extends BaseSearchFilter<?, ID>, D extends Dto<ID>, ID extends Serializable & Comparable<ID>> extends ReadOnlyApi<S, D, ID> {
}

Applications fails with:
Caused by: java.lang.StackOverflowError: null
at org.springframework.core.ResolvableType.hasGenerics(ResolvableType.java:474)
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.resolveVariable(AbstractJackson2HttpMessageConverter.java:326)
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.resolveVariable(AbstractJackson2HttpMessageConverter.java:332)
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.resolveVariable(AbstractJackson2HttpMessageConverter.java:332)
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.resolveVariable(AbstractJackson2HttpMessageConverter.java:332)
...

The issue is in line 332. At some point the method resolveVariable faces Object as result of contextType.getSuperType() and falls with StackOverflowError as result for getSuperType() method for Object is Object.

I tried to check what if there is a check for that and method continues further. Looks like it works well.

There is a code below which i added to check what happenes if method passes further after line 332

final Class contextTypeSuperType = contextType.getSuperType().resolve();
                if (!(contextTypeSuperType == null || contextTypeSuperType.equals(Object.class))) {
                    resolvedType = resolveVariable(typeVariable, contextType.getSuperType());
                    if (resolvedType.resolve() != null) {
                        return resolvedType;
                    }
                }

I'm not sure that this is a bug, but i do not find any solutions for my case in stackoverflow.com or other similar resources.


Affects: 4.3.1

Attachments:

Issue Links:

Referenced from: commits 7c5050c, e86529e

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Might be worth trying Spring Framework 4.3.2 which contains a minor revision of Jackson type handling... Sébastien Deleuze, could you confirm?

@spring-projects-issues
Copy link
Collaborator Author

Gerasimov Gennady commented

4.3.2 did not help in my case. i've checked it.

@spring-projects-issues
Copy link
Collaborator Author

Gerasimov Gennady commented

I hope attached test can help to reproduce the issue

@spring-projects-issues
Copy link
Collaborator Author

Sébastien Deleuze commented

Thanks I will have a look ASAP.

@spring-projects-issues
Copy link
Collaborator Author

Sébastien Deleuze commented

This issue should be fixed in both master and 4.3.x. Could you please give a try with latest snapshot Gerasimov Gennady?

@spring-projects-issues
Copy link
Collaborator Author

Gerasimov Gennady commented

Yes, it works, Thx!

@spring-projects-issues spring-projects-issues added type: bug A general bug in: core Issues in core modules (aop, beans, core, context, expression) in: web Issues in web modules (web, webmvc, webflux, websocket) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.3.3 milestone Jan 11, 2019
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) in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants