Skip to content

Commit 5b3a22e

Browse files
committed
GH-1294 Additional changes related to removal of TARGET_PROTOCOL
1 parent 1a81d35 commit 5b3a22e

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
@@ -141,7 +141,8 @@ public static boolean isTypeMap(Type type) {
141141
}
142142

143143
public static boolean isTypeArray(Type type) {
144-
return getRawType(type).isArray();
144+
return type instanceof GenericArrayType;
145+
// return getRawType(type).isArray();
145146
}
146147

147148
public static boolean isJsonNode(Type type) {
@@ -542,8 +543,13 @@ public static boolean isFlux(Type type) {
542543
}
543544

544545
public static boolean isCollectionOfMessage(Type type) {
545-
if (isMessage(type) && isTypeCollection(type)) {
546-
return isMessage(getImmediateGenericType(type, 0));
546+
if (isMessage(type) && (isTypeCollection(type) || isTypeArray(type))) {
547+
if (isTypeCollection(type)) {
548+
return isMessage(getImmediateGenericType(type, 0));
549+
}
550+
else if (type instanceof GenericArrayType arrayType) {
551+
return true;
552+
}
547553
}
548554
return false;
549555
}
@@ -552,6 +558,9 @@ public static boolean isMessage(Type type) {
552558
if (isPublisher(type)) {
553559
type = getImmediateGenericType(type, 0);
554560
}
561+
if (type instanceof GenericArrayType arrayType) {
562+
type = arrayType.getGenericComponentType();
563+
}
555564

556565
Class<?> resolveRawClass = FunctionTypeUtils.getRawType(type);
557566
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)