Skip to content

Instantly share code, notes, and snippets.

@jloisel
Created September 17, 2015 09:26
Show Gist options
  • Save jloisel/1d36c017f5b27617c27b to your computer and use it in GitHub Desktop.
Save jloisel/1d36c017f5b27617c27b to your computer and use it in GitHub Desktop.
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.junit.Test;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
public class JacksonStackoverflowTest {
private final ObjectMapper mapper = new ObjectMapper();
@Test
public void shouldNotStackOverflow() throws JsonProcessingException {
List<Pair<String, Double>> list = new ArrayList<>();
list.add(ImmutablePair.of("Hello World!", 123d));
// Throws StackOverflow error
mapper.writeValueAsString(list);
}
}
@jloisel
Copy link
Author

jloisel commented Sep 23, 2015

I tried to reproduce with hand-made ImmutablePair and i could not reproduce it yet. There is something with the abstract or interfaces implemented in commons-lang3 which messes up the serialization.

Were you able to run this junit on your side? Anyway, it works fine with 2.5.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment