GH-475 Fix support for Flux<List> type conversion
At the moment support is rudimentary but given that BeanFactoryAwareFunctionRegistry provides all the necessary type conversion functionality the true fix should consider utilizing it. Resolves #475
This commit is contained in:
@@ -145,7 +145,7 @@ public class RequestProcessor {
|
||||
Type jsonType = body.startsWith("[")
|
||||
&& Collection.class.isAssignableFrom(inputType)
|
||||
|| body.startsWith("{") ? inputType : Collection.class;
|
||||
if (body.startsWith("[")) {
|
||||
if (body.startsWith("[") && itemType instanceof Class) {
|
||||
jsonType = ResolvableType.forClassWithGenerics((Class<?>) jsonType,
|
||||
(Class<?>) itemType).getType();
|
||||
}
|
||||
|
||||
@@ -351,6 +351,15 @@ public class HttpPostIntegrationTests {
|
||||
String.class).getBody()).isEqualTo("{\"A\":2,\"B\":1}");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fluxWithList() throws Exception {
|
||||
List<String> list = Arrays.asList("A", "B", "A");
|
||||
assertThat(this.rest.exchange(
|
||||
RequestEntity.post(new URI("/fluxCollectionEcho")).accept(MediaType.APPLICATION_JSON)
|
||||
.contentType(MediaType.APPLICATION_JSON).body(list),
|
||||
String.class).getBody()).isEqualTo("[\"A\",\"B\",\"A\"]");
|
||||
}
|
||||
|
||||
private String sse(String... values) {
|
||||
return "data:" + StringUtils.arrayToDelimitedString(values, "\n\ndata:") + "\n\n";
|
||||
}
|
||||
@@ -481,6 +490,11 @@ public class HttpPostIntegrationTests {
|
||||
(map, word) -> map.merge(word, 1, Integer::sum));
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Function<Flux<List<String>>, Flux<String>> fluxCollectionEcho() {
|
||||
return flux -> flux.flatMap(v -> Flux.fromIterable(v));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class Foo {
|
||||
|
||||
Reference in New Issue
Block a user