Skip to content

Do not decode the body of a ResponseEntity<Void> - #1442

Merged
ryanjbaxter merged 1 commit into
spring-cloud:5.0.xfrom
kdelay:fix/response-entity-void-body
Oct 8, 2026
Merged

ryanjbaxter merged 1 commit into
spring-cloud:5.0.xfrom
kdelay:fix/response-entity-void-body

Conversation

@kdelay

@kdelay kdelay commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

A client method returning ResponseEntity<Void> or HttpEntity<Void> fails with UnknownContentTypeException ("no suitable HttpMessageConverter found for response type [class java.lang.Void] and content type [text/plain]") when the server sends a non-JSON body, for example a 202 with a short text message. ResponseEntityDecoder hands Void.class to the delegate decoder.

RestTemplate and RestClient do not read the body for Void response entities. This change does the same and still returns the status and headers.

Tests:

  • The two new SpringDecoderTests cases fail without the fix with the exception above.
  • ./mvnw -P spring -pl spring-cloud-openfeign-core verify passes (456 tests, 0 Checkstyle violations).

@ryanjbaxter

Copy link
Copy Markdown
Contributor

Can you submit this against 5.0.x?

ResponseEntityDecoder passed Void.class on to the delegate decoder, so
a ResponseEntity<Void> or HttpEntity<Void> method failed with
UnknownContentTypeException when the server sent a text/plain or
text/html body. RestTemplate and RestClient skip the body for Void
response entities; do the same here and keep the status and headers.

Signed-off-by: kdelay <kdelay20@gmail.com>
@kdelay
kdelay force-pushed the fix/response-entity-void-body branch from 1b1eba8 to 0996889 Compare October 8, 2026 00:46
@kdelay
kdelay changed the base branch from main to 5.0.x October 8, 2026 00:46
@kdelay

kdelay commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Done. Rebased onto 5.0.x and retargeted the PR; the change applies unchanged there and spring-cloud-openfeign-core verify passes on 5.0.x.

@ryanjbaxter ryanjbaxter added bug Something isn't working and removed waiting-for-triage labels Oct 8, 2026
@ryanjbaxter ryanjbaxter added this to the 5.0.4 milestone Oct 8, 2026
@ryanjbaxter
ryanjbaxter merged commit 33d6115 into spring-cloud:5.0.x Oct 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: Done
Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants