snowdrop-zen / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
1 stars 0 forks source link

Resteasy Reactive: Kotlin `Flow` and `Multi` are not supported in suspend functions #430

Closed snowdrop-bot closed 3 years ago

snowdrop-bot commented 3 years ago

Describe the bug

Flow and Multi cannot be returned from a suspendable function (resteasy reactive).

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

  1. https://code.quarkus.io/?e=resteasy-reactive-jackson&e=kotlin
  2. Add the following code:
import io.smallrye.mutiny.Multi
import io.smallrye.mutiny.coroutines.asMulti
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import javax.enterprise.context.ApplicationScoped
import javax.ws.rs.GET
import javax.ws.rs.Path
import javax.ws.rs.Produces
import javax.ws.rs.core.MediaType

@ApplicationScoped
@Path("/flow")
class FlowResource {

    @GET
    @Path("/1")
    @Produces(MediaType.TEXT_PLAIN)
    suspend fun flow1Method(): Flow<String> { // kotlinx.coroutines.flow.SafeFlow@6b336f3a
        compute()

        return flow {
            emit("1")
            emit("2")
            emit("3")
        }
    }

    @GET
    @Path("/2")
    @Produces(MediaType.TEXT_PLAIN)
    suspend fun multiMethod(): Multi<String> { // io.smallrye.mutiny.operators.multi.builders.EmitterBasedMulti@5eec36c2
        compute()

        return flow {
            emit("1")
            emit("2")
            emit("3")
        }.asMulti()
    }

    private suspend fun compute() {
        delay(1000)
    }
}

Output of uname -a or ver

No response

Output of java -version

Java 11

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.2.3.Final

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

Maven 3.8.1

Additional information

No response


https://github.com/quarkusio/quarkus/issues/20345


$upstream:20345$