Refine check for multiple subscribers
Commit #c187cb2 introduced proactive rejection of multiple subscribers in ReactorClientHttpResponse, instead of hanging indefinitely as per https://github.com/reactor/reactor-netty/issues/503. However FluxReceive also rejects subsequent subscribers if the response is consumed fully, as opposed to being canceled, e.g. as with bodyToMono(Void.class). In that case, a subsequent subscriber causes two competing error signals to be sent, and one gets dropped and logged by reactor-core. This fix ensures that a rejection is raised in ReactorClientHttpResponse only after a cancel() was detected. Issue: SPR-17564
This commit is contained in:
@@ -447,8 +447,9 @@ class DefaultWebClient implements WebClient {
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T> Mono<T> drainBody(ClientResponse response, Throwable ex) {
|
||||
// Ensure the body is drained, even if the StatusHandler didn't consume it,
|
||||
// but ignore errors in case it did consume it.
|
||||
return (Mono<T>) response.bodyToMono(Void.class).onErrorMap(ex2 -> ex).thenReturn(ex);
|
||||
// but ignore exception, in case the handler did consume.
|
||||
return (Mono<T>) response.bodyToMono(Void.class)
|
||||
.onErrorResume(ex2 -> Mono.empty()).thenReturn(ex);
|
||||
}
|
||||
|
||||
private static Mono<WebClientResponseException> createResponseException(ClientResponse response) {
|
||||
|
||||
Reference in New Issue
Block a user