Guys a have a problem. I have a simple class and t...
# jackson-kotlin
a
Guys a have a problem. I have a simple class and test
Copy code
class 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?