After upgrading to 1.5.0 (from 1.4.3) I got this e...
# ktor
j
After upgrading to 1.5.0 (from 1.4.3) I got this error:
Copy code
Caused by: kotlinx.serialization.SerializationException: Class 'ArrayList' is not registered for polymorphic serialization in the scope of 'Collection'.
Partial stacktrace:
Copy code
kotlinx.serialization.SerializationException: Class 'ArrayList' is not registered for polymorphic serialization in the scope of 'Collection'.
Mark the base class as 'sealed' or register the serializer explicitly.
	at kotlinx.serialization.internal.AbstractPolymorphicSerializerKt.throwSubtypeNotRegistered(AbstractPolymorphicSerializer.kt:103)
	at kotlinx.serialization.internal.AbstractPolymorphicSerializerKt.throwSubtypeNotRegistered(AbstractPolymorphicSerializer.kt:113)
	at kotlinx.serialization.PolymorphicSerializerKt.findPolymorphicSerializer(PolymorphicSerializer.kt:96)
	at kotlinx.serialization.internal.AbstractPolymorphicSerializer.serialize(AbstractPolymorphicSerializer.kt:32)
	at kotlinx.serialization.json.internal.StreamingJsonEncoder.encodeSerializableValue(StreamingJsonEncoder.kt:223)
	at kotlinx.serialization.json.Json.encodeToString(Json.kt:73)
	at io.ktor.serialization.SerializationConverter.convertForSend(SerializationConverter.kt:118)
	at io.ktor.features.ContentNegotiation$Feature$install$2.invokeSuspend(ContentNegotiation.kt:146)
	at io.ktor.features.ContentNegotiation$Feature$install$2.invoke(ContentNegotiation.kt)
The new version forgot how to convert a list?
Copy code
install(ContentNegotiation) {
        val jsonConfig = Json(DefaultJson) {
            encodeDefaults = false
        }

        json(jsonConfig)
    }
This is the way I install the feature (just using `json()`fails too)
Going back to 1.4.3 fixes the error...
e
Hey @Jose A., thanks for the notice. Could you file an issue?
j
Will do!
r
@Jose A. Can you please post type of the response here?
j
Copy code
get("/list") {
                val response: Collection<String> = listOf("a", "b")
                call.respond(response)
            }
This triggers the exception. So Collection<String>
I just posted the problem here: https://youtrack.jetbrains.com/issue/KTOR-1795
👍 1
🙏 1
j
Did you try cleaning/invalidating cache?
j
Same result
r
opened PR with the fix. target - 1.5.1
🙏 1
🎉 1
thanks for the report!
j
Thanks for the fast response!