APXEOLOG
11/03/2018, 3:38 PMclass SomeClass {
fun getListOfSelf(): List<SomeClass> {
return listOf(this)
}
}
/**
* com.fasterxml.jackson.databind.JsonMappingException: Infinite recursion (StackOverflowError)
* (through reference chain: java.util.Collections$SingletonList[0]
* ->core.PlaneTest$SomeClass["listOfSelf"]
* ->java.util.Collections$SingletonList[0]
* ->core.PlaneTest$SomeClass["listOfSelf"]
* ...
*/
@Test
fun testJackson() {
val mapped = jacksonObjectMapper()
val data = SomeClass()
val result = mapped.writeValueAsString(data)
}
This test fails with stackoverflow (chain serialization of self)
If i remove fun getListOfSelf
from the class it works properly.
Why this function is serialized? Wtf?