INT-1133 AbstractReplyProducingMessageHandler no longer copies headers from the request Message into the reply Message IF the return value from the handler implementation is already a Message instance.
This commit is contained in:
@@ -59,7 +59,11 @@ public abstract class AbstractRemotingOutboundGateway extends AbstractReplyProdu
|
||||
}
|
||||
Message<?> requestMessage = MessageBuilder.fromMessage(message).build();
|
||||
try {
|
||||
return this.proxy.exchange(requestMessage);
|
||||
Message<?> reply = this.proxy.exchange(requestMessage);
|
||||
if (reply != null) {
|
||||
reply = MessageBuilder.fromMessage(reply).copyHeadersIfAbsent(message.getHeaders()).build();
|
||||
}
|
||||
return reply;
|
||||
}
|
||||
catch (RemoteAccessException e) {
|
||||
throw new MessageHandlingException(message, "remote failure in Messaging Gateway", e);
|
||||
|
||||
@@ -115,16 +115,11 @@ public abstract class AbstractReplyProducingMessageHandler extends AbstractMessa
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Message<?> createReplyMessage(Object reply, MessageHeaders requestHeaders) {
|
||||
MessageBuilder<?> builder = null;
|
||||
if (reply instanceof MessageBuilder) {
|
||||
builder = (MessageBuilder<?>) reply;
|
||||
}
|
||||
else if (reply instanceof Message) {
|
||||
builder = MessageBuilder.fromMessage((Message) reply);
|
||||
}
|
||||
else {
|
||||
builder = MessageBuilder.withPayload(reply);
|
||||
if (reply instanceof Message) {
|
||||
return (Message<?>) reply;
|
||||
}
|
||||
MessageBuilder<?> builder = (reply instanceof MessageBuilder)
|
||||
? (MessageBuilder<?>) reply : MessageBuilder.withPayload(reply);
|
||||
builder.copyHeadersIfAbsent(requestHeaders);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,7 +20,6 @@ import java.util.concurrent.CountDownLatch;
|
||||
|
||||
import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.message.StringMessage;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
@@ -48,10 +47,10 @@ public class TestHandler {
|
||||
}
|
||||
|
||||
@ServiceActivator
|
||||
public Message<?> handle(Message<?> message) {
|
||||
public String handle(Message<?> message) {
|
||||
this.messageString = message.getPayload().toString();
|
||||
this.latch.countDown();
|
||||
return (this.replyMessageText != null) ? new StringMessage(this.replyMessageText) : null;
|
||||
return (this.replyMessageText != null) ? this.replyMessageText : null;
|
||||
}
|
||||
|
||||
public String getMessageString() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,7 +18,6 @@ package org.springframework.integration.filter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@@ -51,7 +50,7 @@ public class MessageFilterTests {
|
||||
filter.handleMessage(message);
|
||||
Message<?> received = output.receive(0);
|
||||
assertEquals(message.getPayload(), received.getPayload());
|
||||
assertNotSame(message.getHeaders().getId(), received.getHeaders().getId());
|
||||
assertEquals(message.getHeaders().getId(), received.getHeaders().getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user