GH-1052 Fix collection/array processing for AWS invocations with Publisher input type functions
Resolves #1052
This commit is contained in:
@@ -820,7 +820,12 @@ public class SimpleFunctionRegistry implements FunctionRegistry {
|
||||
if (!this.isRoutingFunction() && !(input instanceof Publisher)) {
|
||||
Object payload = input;
|
||||
if (input instanceof Message) {
|
||||
payload = ((Message) input).getPayload();
|
||||
if (((Message) input).getHeaders().containsKey("payload")) {
|
||||
payload = ((Message) input).getHeaders().get("payload");
|
||||
}
|
||||
else {
|
||||
payload = ((Message) input).getPayload();
|
||||
}
|
||||
}
|
||||
if (JsonMapper.isJsonStringRepresentsCollection(payload)
|
||||
&& !FunctionTypeUtils.isTypeCollection(this.inputType) && !FunctionTypeUtils.isTypeArray(this.inputType)) {
|
||||
|
||||
@@ -39,6 +39,9 @@ public abstract class JsonMapper {
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T fromJson(Object json, Type type) {
|
||||
if (json instanceof Collection<?>) {
|
||||
if (FunctionTypeUtils.isTypeCollection(type)) {
|
||||
return (T) json;
|
||||
}
|
||||
Collection<?> inputs = (Collection<?>) json;
|
||||
Type itemType = FunctionTypeUtils.getImmediateGenericType(type, 0);
|
||||
Collection<?> results = FunctionTypeUtils.getRawType(type).isAssignableFrom(List.class)
|
||||
@@ -112,6 +115,9 @@ public abstract class JsonMapper {
|
||||
|
||||
public static boolean isJsonStringRepresentsCollection(Object value) {
|
||||
boolean isJson = false;
|
||||
if (value instanceof Iterable && !value.getClass().getPackage().getName().startsWith("reactor.util.function")) {
|
||||
return true;
|
||||
}
|
||||
if (value instanceof byte[]) {
|
||||
value = new String((byte[]) value, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user