From b496ce6f349cef65b2e9a533733f91ad7b30a8ca Mon Sep 17 00:00:00 2001 From: richmeyer7 Date: Thu, 7 May 2020 12:08:26 -0700 Subject: [PATCH] Update Server Requesters IAW observed behavior In spring-messaging-5.2.5-RELEASE, I observed in the debugger that to successfully complete the connection setup after intercepting and caching a Server Requester, the Kotlin @ConnectMapping method must declare a return type of Mono? and then return null. Any other declared return type or a non-null return value, including Mono.empty(), caused AbstractEncoderMethodReturnValueHandler.handleReturnValue(...) to fall through to the code after this `if` block: ``` if (returnValue == null) { return handleNoContent(returnType, message); } ``` and that resulted in a failure to establish the connection with a RejectedSetupException. --- src/docs/asciidoc/rsocket.adoc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/docs/asciidoc/rsocket.adoc b/src/docs/asciidoc/rsocket.adoc index cc5ee2ea1d41..6e82ac19b72f 100644 --- a/src/docs/asciidoc/rsocket.adoc +++ b/src/docs/asciidoc/rsocket.adoc @@ -454,27 +454,31 @@ decoupled from handling. For example: .subscribe(bar -> { // <1> // ... }); - return ... // <2> + // ... <2> + return null; // <3> } ---- <1> Start the request asynchronously, independent from handling. -<2> Perform handling and return completion `Mono`. +<2> Perform handling. +<3> Return null. Any other return value results in connection failure with RejectedSetupException. [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] .Kotlin ---- @ConnectMapping - suspend fun handle(requester: RSocketRequester) { + suspend fun handle(requester: RSocketRequester): Mono? { GlobalScope.launch { requester.route("status").data("5").retrieveFlow().collect { // <1> // ... } } - /// ... <2> + // ... <2> + return null <3> } ---- <1> Start the request asynchronously, independent from handling. <2> Perform handling in the suspending function. +<3> Return null. Any other return value results in connection failure with RejectedSetupException.