GH-816 Fix support for function that returns Iterable with target-protocol set
Resolves #816
This commit is contained in:
@@ -96,7 +96,7 @@ public final class FunctionTypeUtils {
|
||||
}
|
||||
type = getGenericType(type);
|
||||
Class<?> rawType = type instanceof ParameterizedType ? getRawType(type) : (Class<?>) type;
|
||||
return Collection.class.isAssignableFrom(rawType);
|
||||
return Iterable.class.isAssignableFrom(rawType);
|
||||
}
|
||||
|
||||
public static boolean isTypeArray(Type type) {
|
||||
|
||||
@@ -53,6 +53,7 @@ import org.springframework.cloud.function.context.FunctionProperties.FunctionCon
|
||||
import org.springframework.cloud.function.context.FunctionRegistration;
|
||||
import org.springframework.cloud.function.context.FunctionRegistry;
|
||||
import org.springframework.cloud.function.context.config.RoutingFunction;
|
||||
import org.springframework.cloud.function.context.message.MessageUtils;
|
||||
import org.springframework.cloud.function.core.FunctionInvocationHelper;
|
||||
import org.springframework.cloud.function.json.JsonMapper;
|
||||
import org.springframework.context.expression.BeanFactoryResolver;
|
||||
@@ -1142,7 +1143,13 @@ public class SimpleFunctionRegistry implements FunctionRegistry {
|
||||
convertedOutput = this.convertOutputPublisherIfNecessary((Publisher) output, type, contentType);
|
||||
}
|
||||
else if (output instanceof Message) {
|
||||
convertedOutput = this.convertOutputMessageIfNecessary(output, ObjectUtils.isEmpty(contentType) ? null : contentType[0]);
|
||||
Message m = (Message) output;
|
||||
if (m.getHeaders().containsKey(MessageUtils.TARGET_PROTOCOL) && FunctionTypeUtils.isTypeCollection(this.outputType)) {
|
||||
convertedOutput = this.convertMultipleOutputValuesIfNecessary(m.getPayload(), ObjectUtils.isEmpty(contentType) ? null : contentType);
|
||||
}
|
||||
else {
|
||||
convertedOutput = this.convertOutputMessageIfNecessary(output, ObjectUtils.isEmpty(contentType) ? null : contentType[0]);
|
||||
}
|
||||
}
|
||||
else if (output instanceof Collection && this.isOutputTypeMessage()) {
|
||||
convertedOutput = this.convertMultipleOutputValuesIfNecessary(output, ObjectUtils.isEmpty(contentType) ? null : contentType);
|
||||
|
||||
Reference in New Issue
Block a user