diff --git a/spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/catalog/BeanFactoryAwareFunctionRegistry.java b/spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/catalog/BeanFactoryAwareFunctionRegistry.java index 1d1f7359f..9715454fb 100644 --- a/spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/catalog/BeanFactoryAwareFunctionRegistry.java +++ b/spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/catalog/BeanFactoryAwareFunctionRegistry.java @@ -160,7 +160,6 @@ public T lookup(Class type, String functionDefinition, String... expected else if (functionCandidate instanceof BiFunction || functionCandidate instanceof BiConsumer) { functionRegistration = this.registerMessagingBiFunction(functionCandidate, functionName); } - //else if (KotlinDetector.isKotlinType(functionCandidate.getClass())) { else if (KotlinUtils.isKotlinType(functionCandidate)) { KotlinLambdaToFunctionAutoConfiguration.KotlinFunctionWrapper wrapper = new KotlinLambdaToFunctionAutoConfiguration.KotlinFunctionWrapper(functionCandidate); diff --git a/spring-cloud-function-web/src/main/java/org/springframework/cloud/function/web/util/FunctionWebRequestProcessingHelper.java b/spring-cloud-function-web/src/main/java/org/springframework/cloud/function/web/util/FunctionWebRequestProcessingHelper.java index 6af5bfb7e..c13c9ca29 100644 --- a/spring-cloud-function-web/src/main/java/org/springframework/cloud/function/web/util/FunctionWebRequestProcessingHelper.java +++ b/spring-cloud-function-web/src/main/java/org/springframework/cloud/function/web/util/FunctionWebRequestProcessingHelper.java @@ -16,6 +16,7 @@ package org.springframework.cloud.function.web.util; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -233,15 +234,14 @@ private static Object postProcessResult(Object result, boolean isMessage) { else if (result instanceof Mono) { result = ((Mono) result).map(v -> postProcessResult(v, isMessage)); } - else if (result instanceof Message) { - if (((Message) result).getPayload() instanceof byte[]) { - String str = new String((byte[]) ((Message) result).getPayload()); - result = MessageBuilder.withPayload(str).copyHeaders(((Message) result).getHeaders()).build(); + else if (result instanceof Message messageResult) { + if (messageResult.getPayload() instanceof byte[]) { + //String str = new String((byte[]) messageResult.getPayload()); + result = MessageBuilder.withPayload(messageResult.getPayload()).copyHeaders(((Message) result).getHeaders()).build(); } } - - if (result instanceof byte[]) { - result = new String((byte[]) result); + else if (result instanceof byte[]) { + result = new String((byte[]) result, StandardCharsets.UTF_8); } return result; }