quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.53k stars 2.61k forks source link

Missing kotlinx.serialization serializers #28996

Open mschirmacher opened 1 year ago

mschirmacher commented 1 year ago

Describe the bug

In some situations the serializers generated by kotlinx.serialization are missing/get dropped.

I'm unsure if this should be considered a bug or an enhancement or if this is achievable at all. But let's see.

Given this code:

@Serializable
data class GreetingDto(val message: String)

//@Serializable
//data class AnotherDto(val anotherMessage: String)

@Path("/hello")
class GreetingResource {

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    fun hello() = GreetingDto("Hello from RESTEasy Reactive")

//    @GET
//    @Path("another")
//    fun hello2() = AnotherDto("message")
}

When the application is started in dev mode and you remove the comments the endpoint http://localhost:8080/hello/another should reachable. But querying it quarkus will log exceptions complaining about missing serializers. As these serializers are generated by a maven/gradle plugin i'm not sure if and how quarkus could generate them itself. (these are steps 1.-6. from the repository)

Now when you restart the whole application (with the comment removed, steps 7.-10. from the repository) the endpoint answers as expected. But commenting the lines out and in again the serializers get dropped and exceptions are thrown again.

Expected behavior

No exceptions about missing serializers thrown

Actual behavior

No response

How to Reproduce?

Follow the steps from https://github.com/mschirmacher/missingSerializer

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

quarkus-bot[bot] commented 1 year ago

/cc @evanchooly, @geoand

geoand commented 1 year ago

This happens because when we recompile the Kotlin code, the compiler plugin isn't added.

@glefloch didn't you do something to address this?

geoand commented 1 year ago

I am going to close is as a duplicate of https://github.com/quarkusio/quarkus/issues/2811

glefloch commented 1 year ago

@geoand I think this is not exactly the same issue as #2811, here this is about compiler plugin, not compiler argument. But I thought this was already addressed. I will have a look into it

geoand commented 1 year ago

Ah okay. Thanks

mschorsch commented 9 months ago

I've found a workaround for Gradle: https://github.com/quarkusio/quarkus/issues/37109#issuecomment-1828352002