Source:
<code>private Object transformPayloadForInputChannel(Object payload, String contentType, Collection<MediaType> to) { Object result = null; if (MediaType.APPLICATION_JSON_VALUE.equals(contentType) || XD_JSON_OCTET_STREAM_VALUE.equals(contentType)) { result = transformInputWithTypedJsonMapper(payload, contentType, to); <START> } <END> if (payload instanceof byte[]) if (result != null) { if (to.contains(MediaType.ALL)) { return result; } MediaType toObjectType = findJavaObjectType(to); if (toObjectType != null) { if (toObjectType.getParameter("type") == null) { return result; } String resultClass = result.getClass().getName(); if (resultClass.equals(toObjectType.getParameter("type"))) { return result; } return transformPayloadForInputChannel(result, contentType, Collections.singletonList(toObjectType)); } else if (XD_OCTET_STREAM_VALUE.equals(contentType)) { try { return new String((byte[]) payload, "UTF-8"); } catch (UnsupportedEncodingException e) { logger.error("Could not convert bytes to String", e); } } else if (XD_OCTET_STREAM_VALUE.equals(contentType)) { return payload; } } if (to.contains(MediaType.ALL)) { if (XD_TEXT_PLAIN_UTF8_VALUE.equals(contentType) && payload instanceof byte[]) { try { return new String((byte[]) payload, "UTF-8"); } catch (UnsupportedEncodingException e) { logger.error("Could not convert String to bytes", e); } } return payload; } return convert(payload, to); }</code><technical_language>This right either. Consider a source emits application/json - if target module supports ALL, get JSON, some object decoded JSON. I need separate conversion done for purposes of transporting Vs. conversion some supported type next module restored original payload received source</technical_language>

Target:
private Object transformPayloadForInputChannel(Object payload, String contentType, Collection<MediaType> to) { Object result = null; if (MediaType.APPLICATION_JSON_VALUE.equals(contentType) || XD_JSON_OCTET_STREAM_VALUE.equals(contentType) || XD_JSON_TEXT_VALUE.equals(contentType)) { if (!to.contains(MediaType.ALL) || XD_JSON_OCTET_STREAM_VALUE.equals(contentType)) { result = transformInputWithTypedJsonMapper(payload, contentType, to); } else if (XD_JSON_TEXT_VALUE.equals(contentType)) { result = convertBytesToUTF8String((byte[]) payload); } } if (payload instanceof byte[]) if (result != null) { if (to.contains(MediaType.ALL)) { return result; } MediaType toObjectType = findJavaObjectType(to); if (toObjectType != null) { if (toObjectType.getParameter("type") == null) { return result; } String resultClass = result.getClass().getName(); if (resultClass.equals(toObjectType.getParameter("type"))) { return result; } return transformPayloadForInputChannel(result, contentType, Collections.singletonList(toObjectType)); } else if (XD_OCTET_STREAM_VALUE.equals(contentType)) { try { return new String((byte[]) payload, "UTF-8"); } catch (UnsupportedEncodingException e) { logger.error("Could not convert bytes to String", e); } } else if (XD_OCTET_STREAM_VALUE.equals(contentType)) { return payload; } } if (to.contains(MediaType.ALL)) { if (XD_TEXT_PLAIN_UTF8_VALUE.equals(contentType) && payload instanceof byte[]) { return convertBytesToUTF8String((byte[]) payload); } return payload; } return convert(payload, to); }