From a0457fc5409254dc0019a0908a2a3ef5445a2ca5 Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Sat, 10 Apr 2021 07:56:08 +0200 Subject: [PATCH] GH-608 Additional fix based on provided failed test --- .../context/catalog/SimpleFunctionRegistry.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/catalog/SimpleFunctionRegistry.java b/spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/catalog/SimpleFunctionRegistry.java index 28a05ff21..9f8bbb13a 100644 --- a/spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/catalog/SimpleFunctionRegistry.java +++ b/spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/catalog/SimpleFunctionRegistry.java @@ -822,14 +822,7 @@ public class SimpleFunctionRegistry implements FunctionRegistry, FunctionInspect boolean convertWithHint = false; Type hint = FunctionTypeUtils.getGenericType(type); - convertWithHint = this.useConversionHint(type, rawType); - -// if (FunctionTypeUtils.isTypeCollection(type)) { -// convertWithHint = true; -// } -// else if (!FunctionTypeUtils.isPublisher(type) && !rawType.equals(type) && !FunctionTypeUtils.isMessage(type)) { -// convertWithHint = true; -// } + convertWithHint = this.useConversionHint(type, rawType, hint); convertedValue = convertWithHint ? this.fromMessage((Message) value, (Class) rawType, hint) @@ -867,8 +860,11 @@ public class SimpleFunctionRegistry implements FunctionRegistry, FunctionInspect return convertedValue; } - private boolean useConversionHint(Type type, Type rawType) { - if (FunctionTypeUtils.isTypeCollection(type)) { + private boolean useConversionHint(Type type, Type rawType, Type hint) { + if (hint instanceof ParameterizedType) { + return true; + } + else if (FunctionTypeUtils.isTypeCollection(type)) { return true; } else if (!FunctionTypeUtils.isPublisher(type) && !rawType.equals(type) && !FunctionTypeUtils.isMessage(type)) {