GH-1564 Delegated type-conversion to MessageConverters
The following is the summary of changes which essentially delegate all type conversion back to MessageConverter. The only thing remains is the `BINDER_ORIGINAL_CONTENT_TYPE` logic to ensure backward compatibility * `MessageConverterConfigurer` was brought pretty much back to the state it was before all those questionable type conversion changes * `BinderFactoryConfiguration` configures custom argument resolvers which will be removed as soon as https://jira.spring.io/browse/SPR-17503 is addressed. * The two new argument resolvers, defer from their original counterparts in that they change the order of type assertion ensuring that, for example, byte[] does not match Object and would have to be sent to MessageConverter for possible conversion. These two resolvers will be removed once https://jira.spring.io/browse/SPR-17503 is addressed. Resolves #1564 Resolves #1565
This commit is contained in:
@@ -181,10 +181,10 @@ public abstract class AbstractBinderTests<B extends AbstractTestBinder<? extends
|
||||
binderBindUnbindLatency();
|
||||
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
AtomicReference<Message<String>> inboundMessageRef = new AtomicReference<Message<String>>();
|
||||
AtomicReference<Message<byte[]>> inboundMessageRef = new AtomicReference<Message<byte[]>>();
|
||||
moduleInputChannel.subscribe(message1 -> {
|
||||
try {
|
||||
inboundMessageRef.set((Message<String>) message1);
|
||||
inboundMessageRef.set((Message<byte[]>) message1);
|
||||
}
|
||||
finally {
|
||||
latch.countDown();
|
||||
@@ -194,7 +194,7 @@ public abstract class AbstractBinderTests<B extends AbstractTestBinder<? extends
|
||||
moduleOutputChannel.send(message);
|
||||
Assert.isTrue(latch.await(5, TimeUnit.SECONDS), "Failed to receive message");
|
||||
|
||||
assertThat(inboundMessageRef.get().getPayload()).isEqualTo("foo");
|
||||
assertThat(inboundMessageRef.get().getPayload()).isEqualTo("foo".getBytes());
|
||||
assertThat(inboundMessageRef.get().getHeaders().get(BinderHeaders.BINDER_ORIGINAL_CONTENT_TYPE)).isNull();
|
||||
assertThat(inboundMessageRef.get().getHeaders().get(MessageHeaders.CONTENT_TYPE).toString()).isEqualTo("text/plain");
|
||||
producerBinding.unbind();
|
||||
@@ -386,10 +386,10 @@ public abstract class AbstractBinderTests<B extends AbstractTestBinder<? extends
|
||||
.setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_PLAIN).build();
|
||||
moduleOutputChannel.send(message);
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
AtomicReference<Message<String>> inboundMessageRef = new AtomicReference<Message<String>>();
|
||||
AtomicReference<Message<byte[]>> inboundMessageRef = new AtomicReference<Message<byte[]>>();
|
||||
moduleInputChannel.subscribe(message1 -> {
|
||||
try {
|
||||
inboundMessageRef.set((Message<String>) message1);
|
||||
inboundMessageRef.set((Message<byte[]>) message1);
|
||||
}
|
||||
finally {
|
||||
latch.countDown();
|
||||
@@ -399,7 +399,7 @@ public abstract class AbstractBinderTests<B extends AbstractTestBinder<? extends
|
||||
moduleOutputChannel.send(message);
|
||||
Assert.isTrue(latch.await(5, TimeUnit.SECONDS), "Failed to receive message");
|
||||
assertThat(inboundMessageRef.get()).isNotNull();
|
||||
assertThat(inboundMessageRef.get().getPayload()).isEqualTo("foo");
|
||||
assertThat(inboundMessageRef.get().getPayload()).isEqualTo("foo".getBytes());
|
||||
assertThat(inboundMessageRef.get().getHeaders().get(MessageHeaders.CONTENT_TYPE).toString())
|
||||
.isEqualTo(MimeTypeUtils.TEXT_PLAIN_VALUE);
|
||||
producerBinding.unbind();
|
||||
|
||||
Reference in New Issue
Block a user