Skip to content

Crash with POST requests and WebTestClient: Request body incomplete. #564

@joaoe

Description

@joaoe

Hi.

I'm getting the following crash

java.lang.IllegalArgumentException: Request body incomplete.

	at org.springframework.util.Assert.isTrue(Assert.java:116)
	at org.springframework.test.web.reactive.server.ExchangeResult.getRequestBodyContent(ExchangeResult.java:149)
	at org.springframework.restdocs.webtestclient.WebTestClientRequestConverter.convert(WebTestClientRequestConverter.java:73)
	at org.springframework.restdocs.webtestclient.WebTestClientRequestConverter.convert(WebTestClientRequestConverter.java:60)
	at org.springframework.restdocs.generate.RestDocumentationGenerator.handle(RestDocumentationGenerator.java:199)
	at org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation.lambda$document$0(WebTestClientRestDocumentation.java:81)
	at org.springframework.test.web.reactive.server.DefaultWebTestClient$DefaultBodyContentSpec.lambda$consumeWith$2(DefaultWebTestClient.java:496)
	at org.springframework.test.web.reactive.server.ExchangeResult.assertWithDiagnostics(ExchangeResult.java:194)
	at org.springframework.test.web.reactive.server.DefaultWebTestClient$DefaultBodyContentSpec.consumeWith(DefaultWebTestClient.java:496)
	at MyTest.testMain(MyTest.java:72)

The issue is related with the use of a request body with a post request.
This happens due to an assert Assert.isTrue(MonoProcessor.isTerminated(). Inspecting that method isTerminated returns subscribers == TERMINATED, but in the case of the request body, debugging shows that subscribers == EMPTY.

Testcase follows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: invalidSuggestion or bug report that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions