- 
                Notifications
    You must be signed in to change notification settings 
- Fork 38.8k
Description
Rossen Stoyanchev opened SPR-16018 and commented
Currently .bodyToMono(Void.class) and .bodyToFlux(Void.class) do not do attempt to do anything with the body and simply return Mono.empty() instead.
This is a potential backdoor to connection pool issues if the response does have a body. We need to go farther in the handling of Void to actually attempt to consume the body, and cancel in case we do get some data. This is a sensible default behavior for a call such as .bodyToMono(Void.class) which cannot return anything more useful anyway.
Not only does such an improvement close a loophole into connection pool issues but it also makes for a more consistent message with regards to not leaving unconsumed resources -- instead of a close method on the response which is hard to explain how to use correctly or when, the advice is now simply "always use one of the body methods".
Affects: 5.0 RC4
Issue Links:
- Revisit how WebClient disposes connection [SPR-15993] #20542 Revisit how WebClient disposes connection
- WebClient retrieve() does not handle Void.class as recommended [SPR-16636] #21177 WebClient retrieve() does not handle Void.class as recommended
Referenced from: commits 126ac84