diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/handler/AbstractReplyProducingMessageHandler.java b/org.springframework.integration/src/main/java/org/springframework/integration/handler/AbstractReplyProducingMessageHandler.java index 7b4050b666..88166e2b33 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/handler/AbstractReplyProducingMessageHandler.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/handler/AbstractReplyProducingMessageHandler.java @@ -139,9 +139,16 @@ public abstract class AbstractReplyProducingMessageHandler extends AbstractMessa @SuppressWarnings("unchecked") private Message createReplyMessage(Object reply, MessageHeaders requestHeaders) { - MessageBuilder builder = (reply instanceof MessageBuilder) ? (MessageBuilder) reply - : (reply instanceof Message) ? MessageBuilder.fromMessage((Message) reply) - : MessageBuilder.withPayload(reply); + 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); + } builder.copyHeadersIfAbsent(requestHeaders); return builder.build(); } diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/handler/CollectionAndArrayTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/handler/CollectionAndArrayTests.java index d5b9ef59c5..fd8481c03a 100644 --- a/org.springframework.integration/src/test/java/org/springframework/integration/handler/CollectionAndArrayTests.java +++ b/org.springframework.integration/src/test/java/org/springframework/integration/handler/CollectionAndArrayTests.java @@ -19,7 +19,9 @@ package org.springframework.integration.handler; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; +import static org.hamcrest.CoreMatchers.is; import java.util.Arrays; import java.util.HashSet; @@ -74,7 +76,7 @@ public class CollectionAndArrayTests { Message reply2 = channel.receive(0); assertNotNull(reply1); assertNull(reply2); - assertTrue(Set.class.isAssignableFrom(reply1.getPayload().getClass())); + assertThat(reply1.getPayload(), is(Set.class)); assertEquals(2, ((Set) reply1.getPayload()).size()); }