Skip to content

kotlinx.serialization should not be used for Java interfaces implemented by Java classes #26298

@mickael-coquer

Description

@mickael-coquer

Affects: 5.3.2


Having both Jackson and kotlinx.serialization in the classpath, kotlinx.serialization will try to deserialize Java interfaces implemented by Java classes resulting in the following exception:

org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: Polymorphic serializer was not found for missing class discriminator ('null') ... nested exception is kotlinx.serialization.json.internal.JsonDecodingException: Polymorphic serializer was not found for missing class discriminator ('null') 

The issue comes from the KotlinSerializationJsonHttpMessageConverter.candRead() method that returns true when the Type is a Java interface.

In case of Java concrete implementations, this method should return false and let Jackson handle the conversion.

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions