-
Notifications
You must be signed in to change notification settings - Fork 639
Description
Describe the bug
This is with using spring-cloud-functions 4.3.0
When I define a bean such as the following
import com.amazonaws.lambda.runtime.events.SQSEvent;
@Bean
public Consumer<Message<SQSEvent>> sqsListener() {
return (sqsEvent) -> {
// some implementation
}
}
and try to test this code using the functions-web-adapter. A ClassCastException gets thrown from here https://github.com/spring-cloud/spring-cloud-function/blob/main/spring-cloud-function-adapters/spring-cloud-function-adapter-aws/src/main/java/org/springframework/cloud/function/adapter/aws/AWSTypesMessageConverter.java#L88
The controller from the web-adapter seems to be setting the body of the GenericMessage (org.springframework.messaging.support) to a String and then at line 88 the exception has a message set of
"class java.lang.String cannot be cast to close [B (java.lang.String and [B are in module java.base of loader bootstrap)"
And I think the current code makes sense when ONLY using the aws-adapter since this
will set a byte[]. So I'm partially unsure if the way I'm testing is supposed to be supported. But when using the web-adapter to locally POST to my Cosnsumer, something is picking up the AWSTypesMessageConverter bean and running its converter code likely just because its on the classpath.