quarkus: Kotlin Coroutines Breaks Jackson Serialization

Describe the bug See https://github.com/sherl0cks/kotlin-coroutines-quarkus-graal-jackson-reproducer/blob/master/README.md

It is possible that this should be opened up in https://github.com/oracle/graal. If so, I would appreciate some assistance on that from the Quarkus team as you all have been very responsive and probably have better contacts with Graal than I do.

Expected behavior Jackson works in coroutines like it does without coroutines.

Actual behavior Some variation of the below exception depending on the versions of libraries:

2020-03-19 15:02:43,528 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-1) HTTP Request to /greeting/normal failed, error id: 68a91fde-fc23-44cd-a4e2-3d9735b85543-1: org.jboss.resteasy.spi.UnhandledException: java.lang.IllegalStateException: @NotNull method kotlin/reflect/jvm/internal/impl/builtins/KotlinBuiltIns.getBuiltInClassByFqName must not return null

To Reproduce See https://github.com/sherl0cks/kotlin-coroutines-quarkus-graal-jackson-reproducer/

Environment (please complete the following information): See https://github.com/sherl0cks/kotlin-coroutines-quarkus-graal-jackson-reproducer/

Additional context Kotlin coroutines and graal already have known issues: https://github.com/oracle/graal/issues/366

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (14 by maintainers)

Most upvoted comments

Whether we want to bring some co-routine friendly APIs to Mutiny…

Vert.x actually has pretty decent support for Kotlin’s co-routines already and I hope it works well on GraalVM in the future. 🤞 This way kotlin flow could also provide an alternative to mutiny

No problem at all.

The name of the image itself has not changed, but the image itself has. See https://github.com/quarkusio/quarkus-images/commits/main/quarkus-native-image.yaml for more details

Stumbled upon this issue as I ran into a similar problem. After a bit of testing, it appears that it is not related to coroutines at all, but rather that the Jackson Kotlin module is missing or broken in the native build. If the code can be made to run without the jackson kotlin module, it works both on jvm and native. With and without coroutines.

A simple example, without coroutines, that works on jvm and fails native:

import javax.ws.rs.Consumes
import javax.ws.rs.POST
import javax.ws.rs.Path
import javax.ws.rs.Produces
import javax.ws.rs.core.MediaType

data class Person(
    val name: String,
    val address: Address
)

data class Address(
    val street: String
)

@Path("/hello")
class ExampleResource {

    @POST
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    fun hello(person: Person) = person
}

The error message presented when trying the native build, is the same as one would get on jvm if the kotlin module for jackson is removed.

The above code can be made to run without the kotlin module by changing the Address class to

data class Address(
    @JsonProperty("street")
    val street: String
)

In which case the native build also works.

If the code is wrapped in a coroutine, the actual error is hidden by the kotlin reflect stuff.

Hopefully you are able to get the jackson kotlin module working also in a native build 😃