diff --git a/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayMethodInboundMessageMapper.java b/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayMethodInboundMessageMapper.java index 244503d79f..9634ebc9eb 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayMethodInboundMessageMapper.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayMethodInboundMessageMapper.java @@ -139,6 +139,7 @@ class GatewayMethodInboundMessageMapper implements InboundMessageMapper toMessage(Object[] arguments) { + @Override + public Message toMessage(Object[] arguments) { Assert.notNull(arguments, "cannot map null arguments to Message"); if (arguments.length != this.parameterList.size()) { String prefix = (arguments.length < this.parameterList.size()) ? "Not enough" : "Too many"; @@ -275,7 +277,7 @@ class GatewayMethodInboundMessageMapper implements InboundMessageMapper extends AbstractExpressionEvaluator TypeDescriptor parameterTypeDescriptor = new TypeDescriptor(methodParameter); Class parameterType = parameterTypeDescriptor.getObjectType(); Annotation mappingAnnotation = - MessagingAnnotationUtils.findMessagePartAnnotation(parameterAnnotations[i]); + MessagingAnnotationUtils.findMessagePartAnnotation(parameterAnnotations[i], true); if (mappingAnnotation != null) { Class annotationType = mappingAnnotation.annotationType(); if (annotationType.equals(org.springframework.integration.annotation.Payload.class) diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/MethodInvokingMessageGroupProcessorTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/MethodInvokingMessageGroupProcessorTests.java index ab7a731d10..1961b3aecc 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/MethodInvokingMessageGroupProcessorTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/MethodInvokingMessageGroupProcessorTests.java @@ -56,7 +56,7 @@ import org.springframework.messaging.support.GenericMessage; @RunWith(MockitoJUnitRunner.class) public class MethodInvokingMessageGroupProcessorTests { - private List> messagesUpForProcessing = new ArrayList>(3); + private final List> messagesUpForProcessing = new ArrayList>(3); @Mock private MessageGroup messageGroupMock; @@ -137,11 +137,37 @@ public class MethodInvokingMessageGroupProcessorTests { } @Test - public void shouldFindAnnotatedPayloads() throws Exception { + public void shouldFindListPayloads() throws Exception { @SuppressWarnings("unused") class SimpleAggregator { - public String and(@Payloads List flags, @Header("foo") List header) { + public String and(List flags, @Header("foo") List header) { + List result = new ArrayList(); + for (int flag : flags) { + result.add(flag); + } + for (int flag : header) { + result.add(flag); + } + return result.toString(); + } + } + + MessageGroupProcessor processor = new MethodInvokingMessageGroupProcessor(new SimpleAggregator()); + messagesUpForProcessing.add(MessageBuilder.withPayload(3).setHeader("foo", Arrays.asList(101, 102)).build()); + when(messageGroupMock.getMessages()).thenReturn(messagesUpForProcessing); + Object result = processor.processMessageGroup(messageGroupMock); + assertThat((String) ((Message) result).getPayload(), is("[1, 2, 4, 3, 101, 102]")); + } + + @Test + public void shouldFindAnnotatedPayloadsWithNoType() throws Exception { + + @SuppressWarnings("unused") + class SimpleAggregator { + public String and(@Payloads List rawFlags, @Header("foo") List header) { + @SuppressWarnings("unchecked") + List flags = (List) rawFlags; List result = new ArrayList(); for (int flag : flags) { result.add(flag); @@ -242,6 +268,7 @@ public class MethodInvokingMessageGroupProcessorTests { MethodInvokingMessageGroupProcessor processor = new MethodInvokingMessageGroupProcessor(new SimpleAggregator()); GenericConversionService conversionService = new DefaultConversionService(); conversionService.addConverter(new Converter, Iterator>() { + @Override public Iterator convert(ArrayList source) { return source.iterator(); } @@ -523,6 +550,7 @@ public class MethodInvokingMessageGroupProcessorTests { this.greeting = greeting; } + @Override @Aggregator public String sayHello(List names) { return greeting + " " + names.get(0);