Repository: spring-cloud/spring-cloud-stream
Issue: Support text/* content type for non-SCSt applications

When deserializing the payload at the consumer endpoint, the non-byte stream payload type requires to use `String` object when the underlying message content-type is of any `text` type contentType (text/plain, text/xml and text/html)


Changed files:
spring-cloud-stream-binders/spring-cloud-stream-binder-test/src/test/java/org/springframework/cloud/stream/binder/MessageChannelBinderSupportTests.java
spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/AbstractBinder.java

diff --git a/spring-cloud-stream-binders/spring-cloud-stream-binder-test/src/test/java/org/springframework/cloud/stream/binder/MessageChannelBinderSupportTests.java b/spring-cloud-stream-binders/spring-cloud-stream-binder-test/src/test/java/org/springframework/cloud/stream/binder/MessageChannelBinderSupportTests.java
index c8389214e..3a2481f68 100644
--- a/spring-cloud-stream-binders/spring-cloud-stream-binder-test/src/test/java/org/springframework/cloud/stream/binder/MessageChannelBinderSupportTests.java
+++ b/spring-cloud-stream-binders/spring-cloud-stream-binder-test/src/test/java/org/springframework/cloud/stream/binder/MessageChannelBinderSupportTests.java
@@ -111,6 +111,19 @@ public class MessageChannelBinderSupportTests {
 		assertNull(reconstructed.get(MessageHeaders.CONTENT_TYPE));
 	}
 
+	@Test
+	public void testStringXML() throws IOException {
+		Message<?> message = MessageBuilder
+				.withPayload("<?xml version=\\"1.0\\" encoding=\\"UTF-8\\" standalone=\\"no\\"?><test></test>")
+				.setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_XML)
+				.build();
+		Message<?> converted = binder.serializePayloadIfNecessary(message).toMessage();
+		assertEquals(MimeTypeUtils.TEXT_PLAIN, contentTypeResolver.resolve(converted.getHeaders()));
+		MessageValues reconstructed = binder.deserializePayloadIfNecessary(converted);
+		assertEquals("<?xml version=\\"1.0\\" encoding=\\"UTF-8\\" standalone=\\"no\\"?><test></test>", reconstructed.getPayload());
+		assertEquals(MimeTypeUtils.TEXT_XML.toString(), reconstructed.get(MessageHeaders.CONTENT_TYPE));
+	}
+
 	@Test
 	public void testContentTypePreserved() throws IOException {
 		Message<String> inbound = MessageBuilder.withPayload("{\\"foo\\":\\"foo\\"}")
diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/AbstractBinder.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/AbstractBinder.java
index a5a2bae91..540aa5f28 100644
--- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/AbstractBinder.java
+++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/AbstractBinder.java
@@ -18,7 +18,6 @@ package org.springframework.cloud.stream.binder;
 
 import static org.springframework.util.MimeTypeUtils.APPLICATION_JSON;
 import static org.springframework.util.MimeTypeUtils.APPLICATION_OCTET_STREAM;
-import static org.springframework.util.MimeTypeUtils.TEXT_PLAIN;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -426,7 +425,7 @@ public abstract class AbstractBinder<T> implements ApplicationContextAware, Init
 	}
 
 	private Object deserializePayload(byte[] bytes, MimeType contentType) {
-		if (TEXT_PLAIN.equals(contentType) || APPLICATION_JSON.equals(contentType)) {
+		if ("text".equalsIgnoreCase(contentType.getType()) || APPLICATION_JSON.equals(contentType)) {
 			try {
 				return new String(bytes, "UTF-8");
 			}