diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/handler/ArgumentArrayMessageMapper.java b/org.springframework.integration/src/main/java/org/springframework/integration/handler/ArgumentArrayMessageMapper.java index b9f76da29f..375dc0dcd8 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/handler/ArgumentArrayMessageMapper.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/handler/ArgumentArrayMessageMapper.java @@ -230,15 +230,22 @@ public class ArgumentArrayMessageMapper implements InboundMessageMapper messageArgumentsMap = new LinkedHashMap(); for (int i = 0; i < this.parameterList.size(); i++) { Object argumentValue = arguments[i]; - MethodParameter methodParam = (MethodParameter) this.parameterList.get(i); - Annotation annotation = this.findMappingAnnotation(methodParam.getParameterAnnotations()); + MethodParameter methodParameter = (MethodParameter) this.parameterList.get(i); + Annotation annotation = this.findMappingAnnotation(methodParameter.getParameterAnnotations()); if (annotation != null) { if (annotation.annotationType().equals(Payload.class)) { + if (((Payload) annotation).value().length() != 0) { + throw new IllegalStateException( + "The Payload annotation does not support an expression when mapping to a Message."); + } messageArgumentsMap.put("payload", argumentValue); + if (mappedMessageOrPayload) { + this.throwExceptionForMultipleMessageOrPayloadParameters(methodParameter); + } mappedMessageOrPayload = true; } else if (annotation.annotationType().equals(Header.class)) { - Object[] header = this.mapHeaderThruAnnotation(annotation, message, methodParam, argumentValue); + Object[] header = this.mapHeaderThruAnnotation(annotation, message, methodParameter, argumentValue); messageArgumentsMap.put((String) header[0], header[1]); } else if (annotation.annotationType().equals(Headers.class)) { @@ -262,11 +269,20 @@ public class ArgumentArrayMessageMapper implements InboundMessageMapper buildMessageFromArgumentMap(Map messageArgumentsMap) { MessageBuilder builder = null; Map headers = null;