spring-projects / spring-projects/spring-framework
WebFlux returns 406 but Spring MVC renders "text/plain" request based on Publisher<?> and String [SPR-17078]
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 60.2k
- Forks
- 38.8k
- Avg merge
- 5d 2h
- Merged PRs (30d)
- 27
Description
Dave Syer opened SPR-17078 and commented
I assume this is a Framework issue (might be Spring Boot I guess, since that's what I use to test it).
Controller:
@GetMapping("/straight")
public Mono<ResponseEntity<Publisher<?>>> straight() {
return Mono.just(ResponseEntity.ok().header("x-foo", "spam")
.body(Mono.from(Flux.just("foo", "bar"))));
}
Test:
@Test
public void straight() throws Exception {
ResponseEntity<String> result = rest.exchange(RequestEntity
.get(new URI("/straight")).accept(MediaType.TEXT_PLAIN).build(),
String.class);
assertThat(result.getBody()).isEqualTo("foo");
assertThat(result.getHeaders()).containsKey("x-foo");
}
The test passes with MVC and fails with Webflux (406 not acceptable).
Affects: 5.0.7
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the supplied /straight controller and straight test on Spring MVC and WebFlux with version 5.0.7, focusing on the ResponseEntity containing a Publisher<?> and the text/plain request. Trace the WebFlux response handling after the 406 occurs. Done means the WebFlux case matches the MVC result, including the foo body and x-foo header.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100