When a WebClient exchange is cancelled at the moment the response is being delivered to the subscriber, subscribing to the response body fails with: java.lang.IllegalStateException: The client response body has been released already due to cancellation.
The cancellation is a normal client action (for example a disposed subscription or a timeout), and the body is subscribed to as part of that same, in-progress delivery, not after the response was released.
Reproduced on spring framework 7.0.x
Failing test that disposes the exchange while the response is being delivered:
https://github.com/jonathansp/spring-framework/blob/7005c0cde4/spring-web/src/test/java/org/springframework/http/client/reactive/ClientHttpConnectorTests.java#L194 this test will fail in main branch.
For short client timeouts it is easier to notice

When a
WebClientexchange is cancelled at the moment the response is being delivered to the subscriber, subscribing to the response body fails with:java.lang.IllegalStateException: The client response body has been released already due to cancellation.The cancellation is a normal client action (for example a disposed subscription or a timeout), and the body is subscribed to as part of that same, in-progress delivery, not after the response was released.
Reproduced on spring framework 7.0.x
Failing test that disposes the exchange while the response is being delivered:
https://github.com/jonathansp/spring-framework/blob/7005c0cde4/spring-web/src/test/java/org/springframework/http/client/reactive/ClientHttpConnectorTests.java#L194 this test will fail in main branch.
For short client timeouts it is easier to notice