Skip to content

Commit 057fd61

Browse files
committed
GH-1294 Additional changes related to removal of TARGET_PROTOCOL
1 parent dd971aa commit 057fd61

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/catalog/FunctionTypeUtils.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ public static boolean isTypeMap(Type type) {
140140
}
141141

142142
public static boolean isTypeArray(Type type) {
143-
return getRawType(type).isArray();
143+
return type instanceof GenericArrayType;
144+
// return getRawType(type).isArray();
144145
}
145146

146147
public static boolean isJsonNode(Type type) {
@@ -537,8 +538,13 @@ public static boolean isFlux(Type type) {
537538
}
538539

539540
public static boolean isCollectionOfMessage(Type type) {
540-
if (isMessage(type) && isTypeCollection(type)) {
541-
return isMessage(getImmediateGenericType(type, 0));
541+
if (isMessage(type) && (isTypeCollection(type) || isTypeArray(type))) {
542+
if (isTypeCollection(type)) {
543+
return isMessage(getImmediateGenericType(type, 0));
544+
}
545+
else if (type instanceof GenericArrayType arrayType) {
546+
return true;
547+
}
542548
}
543549
return false;
544550
}
@@ -547,6 +553,9 @@ public static boolean isMessage(Type type) {
547553
if (isPublisher(type)) {
548554
type = getImmediateGenericType(type, 0);
549555
}
556+
if (type instanceof GenericArrayType arrayType) {
557+
type = arrayType.getGenericComponentType();
558+
}
550559

551560
Class<?> resolveRawClass = FunctionTypeUtils.getRawType(type);
552561
if (type instanceof ParameterizedType && !Message.class.isAssignableFrom(resolveRawClass)) {

spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/catalog/SimpleFunctionRegistry.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,9 @@ public class FunctionInvocationWrapper implements Function<Object, Object>, Cons
452452
Map<String, FunctionConfigurationProperties> funcConfiguration = functionProperties.getConfiguration();
453453
if (!CollectionUtils.isEmpty(funcConfiguration)) {
454454
FunctionConfigurationProperties configuration = funcConfiguration.get(functionDefinition);
455+
if (configuration == null) {
456+
configuration = funcConfiguration.get("default");
457+
}
455458
if (configuration != null) {
456459
propagateInputHeaders = configuration.isCopyInputHeaders();
457460
}
@@ -1177,13 +1180,12 @@ private Message filterOutHeaders(Message message) {
11771180
}
11781181

11791182
private boolean isExtractPayload(Message<?> message, Type type) {
1180-
if (this.propagateInputHeaders || this.isRoutingFunction() || FunctionTypeUtils.isMessage(type)) {
1181-
return false;
1182-
}
11831183
if (FunctionTypeUtils.isCollectionOfMessage(type)) {
11841184
return true;
11851185
}
1186-
1186+
if (this.propagateInputHeaders || this.isRoutingFunction() || FunctionTypeUtils.isMessage(type)) {
1187+
return false;
1188+
}
11871189
Object payload = message.getPayload();
11881190
if ((payload instanceof byte[])) {
11891191
return false;

0 commit comments

Comments
 (0)