Spring Boot BOM: 4.0.0-M1 Component: spring-web Version: 7.0.0-M7 (This worked on 6.2.9, but failed for any Types that contained polymorphism types inside)

It seems that at the moment, the AbstractKotlinSerializationHttpMessageConverter fails to work when I use a ResponseEntity to return a response.

I have taken a picture of the debugger in the scenario, showing that the serializer is null, even though the typeSerializersCache has an Serializer registered under GameSummary.

This seems to happen because the hint given to the serializer method is a ResponseEntity, which has no kotlinx serializer impl, thus causing an error. May also happen with other wrapping types.

Image

Also, as some strange reason, even though it is a KClass, the cache being used is the typeSerializerCache instead of the kTypeSerializerCache. I don't know the details, but this may be a problem too?


The types I declared(simplified):

@Serializable
data class GameSummary(
    val state: GameState
)

enum class GameState {
    LEFT_WON,
    RIGHT_WON,
    TIE,
    ONGOING
}

Comment From: Megamiun

Also, should I also create a issue for the other issue I found with polymorphism on 6.2.9? Or should I just ignore for the moment, as this newest version doesn't present it?

Comment From: sdeleuze

I just tried with Spring Boot 4.0.0-M1 and can't reproduce, so please share a self-contained reproducer via a zip attached to this issue or a link to a repository.

Comment From: Megamiun

My bad, it seems like some info has been missing. Here is the code in just one file.

So, in more details:

I also had a Configuration file, which gives different wrong results if declared or no on this line: https://github.com/Megamiun/reginae-sanguine/blob/bug-report/spring-web/kotlin-serilization/response-entity-failure/server/spring/src/main/kotlin/br/com/reginaesanguine/server/GameController.kt#L19

A video of me reproducing the issue

https://github.com/user-attachments/assets/d71274a7-b283-4e6b-819a-2ac73a7e2914

EDIT:

To reproduce, download the repo, and comment/uncomment the line. Then you can run./gradlew server:spring:bootRun to check.

The paths are: curl --location 'http://localhost:8080/game/response-entity' curl --location 'http://localhost:8080/game/direct'

Comment From: sdeleuze

Ok thanks I can now reproduce.

Comment From: sdeleuze

@Megamiun Fixed, please check 7.0.0-SNAPSHOT to confirm it now works as expected and provide your feedback as a comment.

Comment From: Megamiun

@sdeleuze I may be doing something wrong, but the issue remained here:

Image

The changes I applied are in this commit

Comment From: sdeleuze

The modified files are in spring-webmvc not spring-web.

Comment From: Megamiun

My bad! It is working as expected then! Thanks for the fix!