Source:
public Message<?> toMessage(MethodArgsHolder holder, @Nullable Map<String, Object> headersToMap) { Object messageOrPayload = null; boolean foundPayloadAnnotation = false; Object[] arguments = holder.getArgs(); EvaluationContext methodInvocationEvaluationContext = createMethodInvocationEvaluationContext(arguments); Map<String, Object> headersToPopulate = headersToMap != null ? new HashMap<>(headersToMap) : new HashMap<>(); headersToPopulate.put("gatewayMethod", holder.getMethod()); headersToPopulate.put("gatewayArgs", holder.getArgs()); if (GatewayMethodInboundMessageMapper.this.payloadExpression != null) { messageOrPayload = GatewayMethodInboundMessageMapper.this.payloadExpression.getValue( methodInvocationEvaluationContext); } for (int i = 0; i < GatewayMethodInboundMessageMapper.this.parameterList.size(); i++) { Object argumentValue = arguments[i]; MethodParameter methodParameter = GatewayMethodInboundMessageMapper.this.parameterList.get(i); Annotation annotation = MessagingAnnotationUtils.findMessagePartAnnotation(methodParameter.getParameterAnnotations(), false); if (annotation != null) { if (annotation.annotationType().equals(Payload.class)) { messageOrPayload = processPayloadAnnotation(messageOrPayload, argumentValue, methodParameter, annotation); foundPayloadAnnotation = true; } else { headerOrHeaders(headersToPopulate, argumentValue, methodParameter, annotation); } } else if (messageOrPayload == null) { messageOrPayload = argumentValue; } else if (Map.class.isAssignableFrom(methodParameter.getParameterType())) { processMapArgument(messageOrPayload, foundPayloadAnnotation, headersToPopulate, (Map<?, ?>) argumentValue); } else if (GatewayMethodInboundMessageMapper.this.payloadExpression == null) { throwExceptionForMultipleMessageOrPayloadParameters(methodParameter); } } Assert.isTrue(messageOrPayload != null, () -> "unable to determine a Message or payload parameter on method [" + GatewayMethodInboundMessageMapper.this.method + "]"); populateSendAndReplyTimeoutHeaders(methodInvocationEvaluationContext, headersToPopulate); return buildMessage(headersToPopulate, messageOrPayload, methodInvocationEvaluationContext); }

Target:
public Message<?> toMessage(MethodArgsHolder holder, @Nullable Map<String, Object> headersToMap) { Object messageOrPayload = null; boolean foundPayloadAnnotation = false; Object[] arguments = holder.getArgs(); EvaluationContext methodInvocationEvaluationContext = createMethodInvocationEvaluationContext(arguments); Map<String, Object> headersToPopulate = headersToMap != null ? new HashMap<>(headersToMap) : new HashMap<>(); if (GatewayMethodInboundMessageMapper.this.payloadExpression != null) { messageOrPayload = GatewayMethodInboundMessageMapper.this.payloadExpression.getValue( methodInvocationEvaluationContext, holder); } for (int i = 0; i < GatewayMethodInboundMessageMapper.this.parameterList.size(); i++) { Object argumentValue = arguments[i]; MethodParameter methodParameter = GatewayMethodInboundMessageMapper.this.parameterList.get(i); Annotation annotation = MessagingAnnotationUtils.findMessagePartAnnotation(methodParameter.getParameterAnnotations(), false); if (annotation != null) { if (annotation.annotationType().equals(Payload.class)) { messageOrPayload = processPayloadAnnotation(messageOrPayload, argumentValue, methodParameter, annotation); foundPayloadAnnotation = true; } else { headerOrHeaders(headersToPopulate, argumentValue, methodParameter, annotation); } } else if (messageOrPayload == null) { messageOrPayload = argumentValue; } else if (Map.class.isAssignableFrom(methodParameter.getParameterType())) { processMapArgument(messageOrPayload, foundPayloadAnnotation, headersToPopulate, (Map<?, ?>) argumentValue); } else if (GatewayMethodInboundMessageMapper.this.payloadExpression == null) { throwExceptionForMultipleMessageOrPayloadParameters(methodParameter); } } Assert.isTrue(messageOrPayload != null, () -> "unable to determine a Message or payload parameter on method [" + GatewayMethodInboundMessageMapper.this.method + "]"); populateSendAndReplyTimeoutHeaders(methodInvocationEvaluationContext, holder, headersToPopulate); return buildMessage(holder, headersToPopulate, messageOrPayload, methodInvocationEvaluationContext); }