Skip to content

Refine CancellationException handling in Coroutines endpoints #25975

@sdeleuze

Description

@sdeleuze

As demonstrated in https://github.com/sdeleuze/spring-boot-coroutines-demo, in annotated controller throwing a CancellationException result in a 5xx error. Since CancellationException means "normal cancellation of a coroutine", is it the expected behavior?

In functional controller, with such handler function:

suspend fun cancel(request: ServerRequest): ServerResponse {
	throw CancellationException()
}

The related web endpoint never returns, that's unexpected and not consistent with the annotated variant (cc @poutsma). We should probably fix this, see https://github.com/sdeleuze/spring-boot-coroutines-demo/blob/master/src/test/kotlin/com/example/CoroutinesApplicationTests.kt#L63-L67 for a repro.

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: declinedA suggestion or change that we don't feel we should currently applytype: bugA general bug

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions