snowdrop-zen / quarkus

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

ContextNotActiveException for request scoped bean in Kotlin Flow #389

Closed snowdrop-bot closed 3 years ago

snowdrop-bot commented 3 years ago

Describe the bug

Hi Quarkus Team,

first of all thanks for adding Flow as an option for SSE endpoints.

But currently when using Flow this leads to a ContextNotActiveException, when combining it with the access to a request scoped bean

Kind regards

Expected behavior

The value of the request scoped bean can be accessed within the context of a Flow

Actual behavior

When trying to access a property of the request scoped bean a javax.enterprise.context.ContextNotActiveException is thrown

How to Reproduce?

Request scoped bean @RequestScoped class RequestScopedBean( var user: String? = null )

Endpoint


@Path("/hello")
class ReactiveGreetingResource(private val requestScopedBean: RequestScopedBean) {

    @GET
    @RestSseElementType(MediaType.TEXT_PLAIN)
    fun hello(): Flow<String> = flow {
        emit("Hello RESTEasy Reactive")
        delay(1_000)
        emit("Hello again from ${requestScopedBean.user}")
    }
}

---

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

---

$upstream:18993$