question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

stackOverflow on serialize org.apache.commons.lang3.tuple.Pair

See original GitHub issue
ObjectMapper 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:closed
  • Created 8 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ChinaXingcommented, Mar 30, 2016

I choose Gson instead.

0reactions
cowtowncodercommented, Mar 17, 2016

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found