@RequestMapping("/words")
public ResponseEntity<Flux<Bar>> words() {
return ResponseEntity.ok()
.body(Flux.fromArray(new Bar[] { new Bar("foo"), new Bar("bar") }));
}
Test:
@Test
public void words() {
assertThat(new TestRestTemplate()
.getForObject("http://localhost:" + port + "/words", String.class))
.isEqualTo("[{\"value\":\"foo\"},{\"value\":\"bar\"}]");
}
Exception:
org.junit.ComparisonFailure: expected:<"[[{"value":"foo"},{"value":"bar"}]]"> but was:<"[{"timestamp":1493114601666,"status":500,"error":"Internal Server Error","exception":"org.springframework.http.converter.HttpMessageNotWritableException","message":"Could not write JSON document: Class com.example.Bar not subtype of [simple type, class reactor.core.publisher.Flux<com.example.Bar>] (through reference chain: org.springframework.web.servlet.mvc.method.annotation.ReactiveTypeHandler$CollectedValuesList[0]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Class com.example.Bar not subtype of [simple type, class reactor.core.publisher.Flux<com.example.Bar>] (through reference chain: org.springframework.web.servlet.mvc.method.annotation.ReactiveTypeHandler$CollectedValuesList[0])","path":"/words"}]">
Note that the exception shows up in the response body, not in logs, which is odd.
If you change the @RequestMapping to just return Flux<Bar> it works fine.
Dave Syer opened SPR-15478 and commented
Test:
Exception:
Note that the exception shows up in the response body, not in logs, which is odd.
If you change the
@RequestMapping
to just returnFlux<Bar>
it works fine.Affects: 5.0 RC1
Referenced from: commits c67b0d6
The text was updated successfully, but these errors were encountered: