Skip to content

Fix behavior of ClientResponse bodyToMono and bodyToFlux with Void.class [SPR-16018] #20567

@spring-projects-issues

Description

@spring-projects-issues

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:

Referenced from: commits 126ac84

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions