Webflux Reactive Webclient call with Flux Response and AtomicReference

/**
* This blocking call will return an AtomicReference which contains the response, the first which is received.
* You could also return via your Websocket, by directly passing on the FLux response!
*
* @param client - The Webclient, in this case Netty
* @param input - A String, arbitrary text message (I prefer JSON)
* @return AtomicReference, containing the response
*/
private AtomicReference<List<String>> callFooService(ReactorNettyWebSocketClient client, Flux<String> input) {
AtomicReference<List<String>> actualRef = new AtomicReference<>();

client.execute(getUrl(), session ->
session.send(input.map(session::textMessage))
.thenMany(session.receive().take(1).map(WebSocketMessage::getPayloadAsText))
.collectList()
.doOnNext(actualRef::set)
.then())
.block(TIMEOUT);
assertThat(actualRef.get()).isNotNull();
return actualRef;
}