Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resteasy-Reactive: ExceptionMapper is not called when using Kotlin Flow #25744

Closed
mschorsch opened this issue May 24, 2022 · 3 comments
Closed
Labels
area/kotlin area/rest kind/bug Something isn't working triage/invalid This doesn't seem right

Comments

@mschorsch
Copy link
Contributor

Describe the bug

If an exception is thrown within the Flow, the ExceptionMapper is not called and the request does not end.

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import org.jboss.resteasy.reactive.NoCache
import org.jboss.resteasy.reactive.common.util.RestMediaType
import javax.enterprise.context.ApplicationScoped
import javax.ws.rs.GET
import javax.ws.rs.Path
import javax.ws.rs.Produces
import org.jboss.resteasy.reactive.RestResponse
import org.jboss.resteasy.reactive.server.ServerExceptionMapper
import javax.ws.rs.core.MediaType

class ExceptionMappers {

    @ServerExceptionMapper
    fun handleException(exception: Throwable): RestResponse<String> {
        return RestResponse.ResponseBuilder.serverError<String>().entity("ServerExceptionMapper -> Error").type(MediaType.TEXT_PLAIN).build()
    }
}

@Path("/bug")
@ApplicationScoped
class ReproducerResource {

    @GET
    @Path("1")
    @NoCache
    @Produces(RestMediaType.APPLICATION_NDJSON)
    suspend fun reproduceBug(): Flow<String> {
        return flow {
            emit("Test1")
            if (true) {
                throw IllegalArgumentException("IllegalArgumentException -> Error")
            }
        }
    }
}

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.9.1.Final

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

Maven

Additional information

No response

@mschorsch mschorsch added the kind/bug Something isn't working label May 24, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented May 24, 2022

@geoand
Copy link
Contributor

geoand commented May 24, 2022

This happens by design for all types that stream data. I'll update https://quarkus.io/guides/resteasy-reactive#streaming-support to make a note of this

@geoand geoand closed this as completed May 24, 2022
@geoand geoand added the triage/invalid This doesn't seem right label May 24, 2022
geoand added a commit to geoand/quarkus that referenced this issue May 24, 2022
@mschorsch
Copy link
Contributor Author

OK. Thanks. I had already suspected something like that.

gsmet added a commit that referenced this issue May 24, 2022
Mention exception mappers in streaming response note
gsmet pushed a commit to gsmet/quarkus that referenced this issue May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kotlin area/rest kind/bug Something isn't working triage/invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants