Skip to content

Commit 81edded

Browse files
committed
GH-1251 Additional regression fixes with type discovery
Tthis change specifically addresses the use of generics
1 parent 9838a13 commit 81edded

File tree

1 file changed

+15
-8
lines changed
  • spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/catalog

1 file changed

+15
-8
lines changed

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -379,18 +379,25 @@ public static Type getInputType(Type functionType) {
379379

380380
ResolvableType resolvableFunctionType = ResolvableType.forType(functionType);
381381

382-
ResolvableType resolvableInputType;
383-
if (FunctionTypeUtils.isFunction(functionType)) {
384-
resolvableInputType = resolvableFunctionType.as(Function.class);
385-
}
386-
else {
387-
resolvableInputType = resolvableFunctionType.as(Consumer.class);
388-
}
382+
ResolvableType resolvableInputType = resolvableFunctionType.as(resolvableFunctionType.getRawClass());
383+
389384
if (resolvableInputType.getType() instanceof ParameterizedType) {
390385
return resolvableInputType.getGeneric(0).getType();
391386
}
392387
else {
393-
return Object.class;
388+
// will try another way. See GH-1251
389+
if (FunctionTypeUtils.isFunction(functionType)) {
390+
resolvableInputType = resolvableFunctionType.as(Function.class);
391+
}
392+
else {
393+
resolvableInputType = resolvableFunctionType.as(Consumer.class);
394+
}
395+
if (resolvableInputType.getType() instanceof ParameterizedType) {
396+
return resolvableInputType.getGeneric(0).getType();
397+
}
398+
else {
399+
return Object.class;
400+
}
394401
}
395402
}
396403

0 commit comments

Comments
 (0)