diff --git a/spring-integration-core/src/main/java/org/springframework/integration/handler/AbstractReplyProducingMessageHandler.java b/spring-integration-core/src/main/java/org/springframework/integration/handler/AbstractReplyProducingMessageHandler.java
index 6e482df3ef..438b2674cf 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/handler/AbstractReplyProducingMessageHandler.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/handler/AbstractReplyProducingMessageHandler.java
@@ -57,10 +57,6 @@ public abstract class AbstractReplyProducingMessageHandler extends AbstractMessa
this.outputChannel = outputChannel;
}
- protected MessageChannel getOutputChannel() {
- return this.outputChannel;
- }
-
/**
* Set the timeout for sending reply Messages.
*/
@@ -122,7 +118,6 @@ public abstract class AbstractReplyProducingMessageHandler extends AbstractMessa
this.sendReplyMessage(replyMessage, requestHeaders.getReplyChannel());
}
- @SuppressWarnings("unchecked")
private Message> createReplyMessage(Object reply, MessageHeaders requestHeaders) {
if (reply instanceof Message) {
return MessageBuilder.fromMessage((Message>) reply).copyHeadersIfAbsent(requestHeaders).build();
@@ -144,9 +139,8 @@ public abstract class AbstractReplyProducingMessageHandler extends AbstractMessa
if (logger.isDebugEnabled()) {
logger.debug("handler '" + this + "' sending reply Message: " + replyMessage);
}
- MessageChannel outputChannel = this.getOutputChannel();
- if (outputChannel != null) {
- this.sendMessage(replyMessage, outputChannel);
+ if (this.outputChannel != null) {
+ this.sendMessage(replyMessage, this.outputChannel);
}
else if (replyChannelHeaderValue != null) {
this.sendMessage(replyMessage, replyChannelHeaderValue);
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/handler/BridgeHandler.java b/spring-integration-core/src/main/java/org/springframework/integration/handler/BridgeHandler.java
index 142dadf2f3..4c2e342b3b 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/handler/BridgeHandler.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/handler/BridgeHandler.java
@@ -17,7 +17,6 @@
package org.springframework.integration.handler;
import org.springframework.integration.Message;
-import org.springframework.util.Assert;
/**
* A simple MessageHandler implementation that passes the request Message
@@ -28,7 +27,7 @@ import org.springframework.util.Assert;
* The BridgeHandler can be used as a stopper at the end of an assembly line of
* channels. In this setup the output channel doesn't have to be set, but if the
* output channel is omitted the REPLY_CHANNEL MUST be set on the
- * message.
+ * message. Otherwise, a MessagingException will be thrown at runtime.
*
* @author Mark Fisher
* @author Iwein Fuld
@@ -42,14 +41,7 @@ public class BridgeHandler extends AbstractReplyProducingMessageHandler {
@Override
protected Object handleRequestMessage(Message> requestMessage) {
- if (requestMessage.getHeaders().getReplyChannel() == null) {
- this.verifyOutputChannel();
- }
return requestMessage;
}
- private void verifyOutputChannel() {
- Assert.state(super.getOutputChannel() != null, "Bridge handler requires an output channel");
- }
-
}
diff --git a/spring-integration-core/src/test/java/org/springframework/integration/handler/BridgeHandlerTests.java b/spring-integration-core/src/test/java/org/springframework/integration/handler/BridgeHandlerTests.java
index 868b180e45..f56104a936 100644
--- a/spring-integration-core/src/test/java/org/springframework/integration/handler/BridgeHandlerTests.java
+++ b/spring-integration-core/src/test/java/org/springframework/integration/handler/BridgeHandlerTests.java
@@ -24,8 +24,8 @@ import org.hamcrest.Matcher;
import org.junit.Test;
import org.springframework.integration.Message;
-import org.springframework.integration.MessageHandlingException;
import org.springframework.integration.channel.QueueChannel;
+import org.springframework.integration.core.ChannelResolutionException;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.PollableChannel;
@@ -55,18 +55,17 @@ public class BridgeHandlerTests {
assertThat(reply, sameExceptImmutableHeaders(request));
}
- @Test(expected = MessageHandlingException.class)
+ @Test(expected = ChannelResolutionException.class)
public void missingOutputChannelVerifiedAtRuntime() {
Message> request = new GenericMessage("test");
handler.handleMessage(request);
}
-
- @SuppressWarnings("unchecked")
+
@Test(timeout=1000)
public void missingOutputChannelAllowedForReplyChannelMessages() throws Exception {
PollableChannel replyChannel = new QueueChannel();
- Message request = MessageBuilder.withPayload("tst").setReplyChannel(replyChannel ).build();
- handler.handleMessage(request );
+ Message request = MessageBuilder.withPayload("tst").setReplyChannel(replyChannel ).build();
+ handler.handleMessage(request);
assertThat(replyChannel.receive(), sameExceptImmutableHeaders(request));
}