spring-projects / spring-projects/spring-boot

Possible autoconfigure bug with kotlinx serialization and webflux

Open
#51,840 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
Dominant language
Java
Stars
81.5k
Forks
42.7k
Avg merge
2d 4h
Merged PRs (30d)
65

Description

Using spring-boot-starter-kotlinx-serialization-json seems to work out of the box, but when customizing the Json instance using a KotlinxSerializationJsonBuilderCustomizer it seems like KotlinxSerializationJsonCodecConfiguration doesn't find a Json instance with its @ConditionalOnBean(Json.class). That again leads to the customization not being applied to the Json instance used for json serialization and serialization fails.

I have created a minimal project showing the problem here. In the sample project I've defined a bean matching what KotlinxSerializationJsonCodecConfiguration does, and if that bean is enabled the tests work as expected. The sample project is using Spring Boot 4.1.1 and the same behavior is found in 4.0.8 as well.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with KotlinxSerializationJsonCodecConfiguration and its @ConditionalOnBean(Json.class), then reproduce the behavior in the linked minimal sample project using the KotlinxSerializationJsonBuilderCustomizer. Compare the configured Json bean with the instance used by WebFlux serialization; done means customization is applied and the sample tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kotlin, spring-boot
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.