|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2019 the original author or authors. |
|
|
|
* Copyright 2002-2020 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -209,9 +209,11 @@ public class MappingJackson2MessageConverter extends AbstractMessageConverter { |
|
|
|
JavaType javaType = getJavaType(targetClass, conversionHint); |
|
|
|
JavaType javaType = getJavaType(targetClass, conversionHint); |
|
|
|
Object payload = message.getPayload(); |
|
|
|
Object payload = message.getPayload(); |
|
|
|
Class<?> view = getSerializationView(conversionHint); |
|
|
|
Class<?> view = getSerializationView(conversionHint); |
|
|
|
// Note: in the view case, calling withType instead of forType for compatibility with Jackson <2.5
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
if (payload instanceof byte[]) { |
|
|
|
if (targetClass.isInstance(payload)) { |
|
|
|
|
|
|
|
return payload; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (payload instanceof byte[]) { |
|
|
|
if (view != null) { |
|
|
|
if (view != null) { |
|
|
|
return this.objectMapper.readerWithView(view).forType(javaType).readValue((byte[]) payload); |
|
|
|
return this.objectMapper.readerWithView(view).forType(javaType).readValue((byte[]) payload); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -219,10 +221,8 @@ public class MappingJackson2MessageConverter extends AbstractMessageConverter { |
|
|
|
return this.objectMapper.readValue((byte[]) payload, javaType); |
|
|
|
return this.objectMapper.readValue((byte[]) payload, javaType); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else if (targetClass.isInstance(payload)) { |
|
|
|
|
|
|
|
return payload; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
else { |
|
|
|
|
|
|
|
// Assuming a text-based source payload
|
|
|
|
if (view != null) { |
|
|
|
if (view != null) { |
|
|
|
return this.objectMapper.readerWithView(view).forType(javaType).readValue(payload.toString()); |
|
|
|
return this.objectMapper.readerWithView(view).forType(javaType).readValue(payload.toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -271,7 +271,8 @@ public class MappingJackson2MessageConverter extends AbstractMessageConverter { |
|
|
|
payload = out.toByteArray(); |
|
|
|
payload = out.toByteArray(); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
Writer writer = new StringWriter(); |
|
|
|
// Assuming a text-based target payload
|
|
|
|
|
|
|
|
Writer writer = new StringWriter(1024); |
|
|
|
if (view != null) { |
|
|
|
if (view != null) { |
|
|
|
this.objectMapper.writerWithView(view).writeValue(writer, payload); |
|
|
|
this.objectMapper.writerWithView(view).writeValue(writer, payload); |
|
|
|
} |
|
|
|
} |
|
|
|
|