GH-932 Fix registration of AWSTypesMessageConverter for functional spring applications

Resolves #932
This commit is contained in:
Oleg Zhurakousky
2022-11-10 12:13:57 +01:00
parent b33a106c48
commit 13c79f5283
10 changed files with 55 additions and 244 deletions

View File

@@ -96,6 +96,7 @@ public class FunctionalSpringApplication
Assert.isInstanceOf(GenericApplicationContext.class, context,
"ApplicationContext must be an instanceof GenericApplicationContext");
for (Object source : getAllSources()) {
System.out.println("======> SOURCE: " + source);
Class<?> type = null;
Object handler = null;
if (source instanceof String) {

View File

@@ -926,6 +926,7 @@ public class SimpleFunctionRegistry implements FunctionRegistry, FunctionInspect
if (inputValue instanceof Message && !this.isInputTypeMessage()) {
inputValue = ((Message) inputValue).getPayload();
}
System.out.println("Invoking function: " + this + "with input type: " + this.getInputType());
Object result = ((Function) this.target).apply(inputValue);
if (result instanceof Publisher && functionInvocationHelper != null) {
@@ -1096,7 +1097,8 @@ public class SimpleFunctionRegistry implements FunctionRegistry, FunctionInspect
: convertedInput;
}
if (convertedInput != null && logger.isDebugEnabled()) {
logger.debug("Converted Message: " + input + " to: " + convertedInput);
logger.debug("Converted Message: " + input + " to: " +
(convertedInput instanceof OriginalMessageHolder ? ((OriginalMessageHolder) convertedInput).value.getClass() : convertedInput));
}
}
else {

View File

@@ -176,6 +176,7 @@ public class ContextFunctionCatalogInitializer implements ApplicationContextInit
List<MessageConverter> messageConverters = new ArrayList<>();
JsonMapper jsonMapper = this.context.getBean(JsonMapper.class);
messageConverters.addAll(context.getBeansOfType(MessageConverter.class).values());
messageConverters.add(new JsonMessageConverter(jsonMapper));
messageConverters.add(new ByteArrayMessageConverter());
messageConverters.add(new StringMessageConverter());

View File

@@ -92,7 +92,13 @@ public class JsonMessageConverter extends AbstractMessageConverter {
if (payload instanceof byte[]) {
payload = new String((byte[]) payload, StandardCharsets.UTF_8);
}
logger.warn("Failed to convert value: " + payload, e);
if (logger.isDebugEnabled()) {
logger.debug("Failed to convert value: " + payload + " to: " + targetClass, e);
}
else {
logger.warn("Failed to convert value: " + payload + " to: " + targetClass);
}
}
}
}