stackOverflow on serialize org.apache.commons.lang3.tuple.Pair
See original GitHub issueObjectMapper objectMapper = new ObjectMapper();
try {
JsonGenerator generator = objectMapper.getFactory().createGenerator(System.out);
Pair<Integer, String> a = Pair.of(10, "100");
objectMapper.writer().writeValue(generator, a);
} catch (Exception e) {
e.printStackTrace();
}
will produce stack overflow:
java.lang.StackOverflowError
at com.fasterxml.jackson.databind.type.ClassKey.equals(ClassKey.java:78)
at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:940)
at com.fasterxml.jackson.databind.util.LRUMap.get(LRUMap.java:68)
at com.fasterxml.jackson.databind.type.TypeFactory._fromClass(TypeFactory.java:870)
at com.fasterxml.jackson.databind.type.TypeFactory._constructType(TypeFactory.java:480)
at com.fasterxml.jackson.databind.type.TypeBindings._resolveBindings(TypeBindings.java:314)
at com.fasterxml.jackson.databind.type.TypeBindings._resolve(TypeBindings.java:212)
at com.fasterxml.jackson.databind.type.TypeBindings.findType(TypeBindings.java:126)
at com.fasterxml.jackson.databind.type.TypeFactory._fromVariable(TypeFactory.java:1068)
at com.fasterxml.jackson.databind.type.TypeFactory._constructType(TypeFactory.java:493)
....
at com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:397)
at com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:373)
at com.fasterxml.jackson.databind.type.TypeFactory._fromParamType(TypeFactory.java:1032)
at com.fasterxml.jackson.databind.type.TypeFactory._constructType(TypeFactory.java:484)
at com.fasterxml.jackson.databind.type.TypeBindings._resolveBindings(TypeBindings.java:267)
at com.fasterxml.jackson.databind.type.TypeBindings._resolveBindings(TypeBindings.java:328)
at com.fasterxml.jackson.databind.type.TypeBindings._resolve(TypeBindings.java:212)
at com.fasterxml.jackson.databind.type.TypeBindings.findType(TypeBindings.java:126)
at com.fasterxml.jackson.databind.type.TypeFactory._fromVariable(TypeFactory.java:1068)
at com.fasterxml.jackson.databind.type.TypeFactory._constructType(TypeFactory.java:493)
at com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:397)
at com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:373)
at com.fasterxml.jackson.databind.type.TypeFactory._fromParamType(TypeFactory.java:1032)
at com.fasterxml.jackson.databind.type.TypeFactory._constructType(TypeFactory.java:484)
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Make jackson serialize apache commons Pair - Stack Overflow
How can I make jackson, if even possible without making my own complex serializer of org.apache.commons.lang3.tuple.Pair , to serialize both ...
Read more >Pair (Apache Commons Lang 3.12.0 API)
A pair consisting of two elements. This class is an abstract implementation defining the basic API. It refers to the elements as 'left'...
Read more >StackOverFlow error / hanging when trying to serialize classes ...
Has anyone had any experience with trying to get classes that extend java.lang.Exception to work with Kryo? I'm registering the classes using ...
Read more >org.apache.commons.lang3.tuple.Pair.<init> java ... - Tabnine
Best Java code snippets using org.apache.commons.lang3.tuple.Pair.<init> (Showing top 3 results out of 2,610) · Sort an array based on an index array in...
Read more >polymorphism in java docs Code Example
NoClassDefFoundError: org/apache/commons/logging/LogFactory ... all combinations of well-formed parentheses for n pairs of them, in Java?
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I choose Gson instead.
@ChinaXing Jackson 2.7 has a completely rewritten type resolution system, and I was asking because problems previous versions had can not be fixed for those versions in patches. There were a few known issues and this could be one of those.
I would suggest you to see whether things work with 2.7.3; I would expect that to handle recursion better.