Skip to content

InvocableHandlerMethod fails to resolve Object payload after resolving Map payload #3004

Closed
@L00kian

Description

@L00kian

Hello,

I faced an issue using 5.2.0.M2 release that didn't appear in 5.1.6

When having two GenericHandler implementation sequentially handling the message if the first handler is a subtype of Map the second fails with ClassCastException due to attempted use of cached MapArgumentResolver which was used for the first invocation

I nailed the code facing the issue to a small program below.

I'm not 100% certain about that but in 5.1.6 the HandlerMethodArgumentResolverComposite didn't seem to have anything at all for the second invocation after the first one


@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args).getBean("inputChannel", DirectChannel.class)
                .send(new GenericMessage<>(Collections.singletonMap("key", "value")));
    }

    @Bean
    public DirectChannel inputChannel() {
        return MessageChannels.direct().get();
    }

    @Bean
    public IntegrationFlow sampleFlow() {
        return IntegrationFlows.from(inputChannel())
                .handle(new SampleMapHandler())
                .handle(new SampleHandler())
                .handle(message -> {
                }).get();
    }

    public static class SampleHandler implements GenericHandler<String> {

        @Override
        public String handle(String stringPayload, MessageHeaders messageHeaders) {
            return stringPayload + " World!";
        }
    }

    public static class SampleMapHandler implements GenericHandler<Map<String, String>> {

        @Override
        public String handle(Map<String, String> mapPayload, MessageHeaders messageHeaders) {
            return "Hello " + mapPayload.get("key");
        }
    }
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions