polishing
If no converter is found, the MessageConversionException now contains the message instance that could not be handled Issue: SPR-11817
This commit is contained in:
parent
987806f7c2
commit
e4ad9c5204
|
@ -67,9 +67,9 @@ public abstract class AbstractMessageReceivingTemplate<D> extends AbstractMessag
|
|||
MessageConverter messageConverter = getMessageConverter();
|
||||
T value = (T) messageConverter.fromMessage(message, targetClass);
|
||||
if (value == null) {
|
||||
throw new MessageConversionException("Unable to convert payload='"
|
||||
throw new MessageConversionException(message, "Unable to convert payload='"
|
||||
+ message.getPayload() + "' to type='" + targetClass
|
||||
+ "', converter=[" + messageConverter + "]");
|
||||
+ "', converter=[" + messageConverter + "]", null);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -29,8 +29,7 @@ import org.springframework.messaging.converter.MessageConversionException;
|
|||
import org.springframework.messaging.support.GenericMessage;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.isA;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.Writer;
|
||||
|
||||
|
@ -118,10 +117,13 @@ public class MessageReceivingTemplateTests {
|
|||
this.template.setDefaultDestination("home");
|
||||
this.template.setReceiveMessage(expected);
|
||||
this.template.setMessageConverter(new GenericMessageConverter(new DefaultConversionService()));
|
||||
|
||||
thrown.expect(MessageConversionException.class);
|
||||
thrown.expectMessage("payload");
|
||||
this.template.receiveAndConvert(Writer.class);
|
||||
try {
|
||||
this.template.receiveAndConvert(Writer.class);
|
||||
}
|
||||
catch (MessageConversionException e) {
|
||||
assertTrue("Invalid exception message '"+e.getMessage()+"'", e.getMessage().contains("payload"));
|
||||
assertSame(expected, e.getFailedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue