GH-609 Fix support for missmatched Publishers

Given that s-c-f-web always sends input as Flux, it creates issues for Function<Mono, Mono>, so this fixes it
Resolves #609
This commit is contained in:
Oleg Zhurakousky
2020-11-20 12:13:52 +01:00
parent 2e119a3dd6
commit 9d1d74cc76
2 changed files with 18 additions and 0 deletions

View File

@@ -1088,6 +1088,12 @@ public class SimpleFunctionRegistry implements FunctionRegistry, FunctionInspect
*/
@SuppressWarnings("unchecked")
private Object convertInputPublisherIfNecessary(Publisher publisher, Type type) {
if (FunctionTypeUtils.isMono(type) && publisher instanceof Flux) {
publisher = Mono.from(publisher);
}
else if (FunctionTypeUtils.isFlux(type) && publisher instanceof Mono) {
publisher = Flux.from(publisher);
}
Type actualType = type != null ? FunctionTypeUtils.getGenericType(type) : type;
return publisher instanceof Mono
? Mono.from(publisher).map(v -> this.convertInputIfNecessary(v, actualType))