Webflux fails to apply the rule for controller methods returning void to kotlin suspend functions returning Unit #27629
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
theme: kotlin
An issue related to Kotlin support
type: bug
A general bug
Milestone
Affects: 5.3.12
Webflux fails to apply the rule for controller methods returning void to suspend functions returning Unit. Code like the example below causes error messages in log:
ERROR o.s.w.s.a.HttpWebHandlerAdapter - [882bce24-1] Error [java.lang.UnsupportedOperationException] for HTTP POST "/some/api/path", but ServerHttpResponse already committed (200 OK)
Cause
InvocableHandlerMethod::invoke
wraps coroutine results with either mono or flux usingCoroutinesUtils.invokeSuspendingFunction
, butgetReturnType
simply returnsVoid.class
. This in turn causesreactiveAdapterRegistry.getAdapter
to returnnull
andisAsyncVoidReturnType
to returnfalse
Workaround
Remove suspend modifier and replicate
CoroutinesUtils.invokeSuspendingFunction
wrapping manually:The text was updated successfully, but these errors were encountered: