Skip to content

WebClient throws IllegalStateException on response body when cancelled during response delivery #37204

Description

@jonathansp

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

Image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: supersededAn issue that has been superseded by another

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions