Source:
protected Object handleRequestMessage(Message<?> requestMessage) { final Object requestPayload = requestMessage.getPayload(); final Object targetPayload; if (requestPayload instanceof Cloneable && this.shouldClonePayload) { try { Method cloneMethod = requestPayload.getClass().getMethod("clone"); targetPayload = ReflectionUtils.invokeMethod(cloneMethod, requestPayload); } catch (Exception e) { throw new MessageHandlingException(requestMessage, "Failed to clone payload object", e); } } else { targetPayload = requestPayload; } final Message<?> actualRequestMessage; if (this.requestPayloadExpression == null) { actualRequestMessage = requestMessage; } else { final Object requestMessagePayload = this.requestPayloadExpression.getValue(this.sourceEvaluationContext, requestMessage); actualRequestMessage = MessageBuilder.withPayload(requestMessagePayload) .copyHeaders(requestMessage.getHeaders()).build(); } final Message<?> replyMessage; if (this.gateway == null) { replyMessage = actualRequestMessage; } else { replyMessage = this.gateway.sendAndReceiveMessage(actualRequestMessage); if (replyMessage == null) { return replyMessage; } } for (Map.Entry<Expression, Expression> entry : this.propertyExpressions.entrySet()) { Expression propertyExpression = entry.getKey(); Expression valueExpression = entry.getValue(); Object value = valueExpression.getValue(this.sourceEvaluationContext, replyMessage); propertyExpression.setValue(this.targetEvaluationContext, targetPayload, value); } if (this.headerExpressions.isEmpty()) { return targetPayload; } Map<String, Object> targetHeaders = new HashMap<String, Object>(this.headerExpressions.size()); for (Map.Entry<String, Expression> entry : this.headerExpressions.entrySet()) { String header = entry.getKey(); Expression valueExpression = entry.getValue(); Object value = valueExpression.getValue(this.sourceEvaluationContext, replyMessage); targetHeaders.put(header, value); } return MessageBuilder.withPayload(targetPayload).copyHeaders(targetHeaders).build(); }

Target:
protected Object handleRequestMessage(Message<?> requestMessage) { final Object requestPayload = requestMessage.getPayload(); final Object targetPayload; if (requestPayload instanceof Cloneable && this.shouldClonePayload) { try { Method cloneMethod = requestPayload.getClass().getMethod("clone"); targetPayload = ReflectionUtils.invokeMethod(cloneMethod, requestPayload); } catch (Exception e) { throw new MessageHandlingException(requestMessage, "Failed to clone payload object", e); } } else { targetPayload = requestPayload; } final Message<?> actualRequestMessage; if (this.requestPayloadExpression == null) { actualRequestMessage = requestMessage; } else { final Object requestMessagePayload = this.requestPayloadExpression.getValue(this.sourceEvaluationContext, requestMessage); actualRequestMessage = MessageBuilder.withPayload(requestMessagePayload) .copyHeaders(requestMessage.getHeaders()).build(); } final Message<?> replyMessage; if (this.gateway == null) { replyMessage = actualRequestMessage; } else { replyMessage = this.gateway.sendAndReceiveMessage(actualRequestMessage); if (replyMessage == null) { return replyMessage; } } for (Map.Entry<Expression, Expression> entry : this.propertyExpressions.entrySet()) { Expression propertyExpression = entry.getKey(); Expression valueExpression = entry.getValue(); Object value = valueExpression.getValue(this.sourceEvaluationContext, replyMessage); propertyExpression.setValue(this.targetEvaluationContext, targetPayload, value); } if (this.headerExpressions.isEmpty()) { return targetPayload; } else { Map<String, Object> targetHeaders = new HashMap<String, Object>(this.headerExpressions.size()); for (Map.Entry<String, HeaderValueMessageProcessor<?>> entry : this.headerExpressions.entrySet()) { String header = entry.getKey(); HeaderValueMessageProcessor<?> valueProcessor = entry.getValue(); Boolean overwrite = valueProcessor.isOverwrite(); overwrite = overwrite != null ? overwrite : true; if (overwrite || !requestMessage.getHeaders().containsKey(header)) { Object value = valueProcessor.processMessage(replyMessage); targetHeaders.put(header, value); } } return MessageBuilder.withPayload(targetPayload).copyHeaders(targetHeaders).build(); } }