GH-489 the received data which Post Flux data to FunctionController is not same as the function apply
fix test case
This commit is contained in:
@@ -206,7 +206,7 @@ public class RequestProcessor {
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
private Mono<ResponseEntity<?>> response(FunctionWrapper wrapper, Object body,
|
||||
public Mono<ResponseEntity<?>> response(FunctionWrapper wrapper, Object body,
|
||||
boolean stream) {
|
||||
|
||||
Function function = wrapper.function();
|
||||
@@ -215,8 +215,9 @@ public class RequestProcessor {
|
||||
if (Collection.class
|
||||
.isAssignableFrom(this.inspector.getInputType(wrapper.handler()))) {
|
||||
flux = Flux.just(body);
|
||||
}
|
||||
else {
|
||||
} else if (body instanceof Flux) {
|
||||
flux = Flux.from((Flux) body);
|
||||
} else {
|
||||
Iterable<?> iterable = body instanceof Collection ? (Collection<?>) body
|
||||
: (body instanceof Set ? Collections.singleton(body)
|
||||
: Collections.singletonList(body));
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.cloud.function.web.RequestProcessor;
|
||||
@@ -100,9 +101,9 @@ public class FunctionController {
|
||||
@PostMapping(path = "/**", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
|
||||
@ResponseBody
|
||||
public Mono<ResponseEntity<?>> postStream(ServerWebExchange request,
|
||||
@RequestBody(required = false) String body) {
|
||||
FunctionWrapper wrapper = wrapper(request);
|
||||
return this.processor.post(wrapper, body, true);
|
||||
@RequestBody(required = false) Flux<String> body) {
|
||||
final FunctionWrapper wrapper = wrapper(request);
|
||||
return this.processor.response(wrapper, body, true);
|
||||
}
|
||||
|
||||
@GetMapping(path = "/**")
|
||||
|
||||
Reference in New Issue
Block a user