This commit is contained in:
Timothy Bish 2018-07-09 17:40:39 -04:00
commit 8989da1a6a
2 changed files with 11 additions and 8 deletions

View File

@ -451,9 +451,12 @@ public class CoreAmqpConverter {
// this will represent a readOnly buffer for the message
ActiveMQBuffer buffer = internalMessage.getDataBuffer();
try {
Object s = buffer.readNullableSimpleString();
if (s != null) {
body = new AmqpValue(s.toString());
// the buffer may be completely empty (e.g. if the original AMQP message had a null body)
if (buffer.readableBytes() > 0) {
Object s = buffer.readNullableSimpleString();
if (s != null) {
body = new AmqpValue(s.toString());
}
}
} catch (Throwable ignored) {
logger.debug("Exception ignored during conversion", ignored.getMessage(), ignored);

View File

@ -341,11 +341,11 @@ public class JMSMappingOutboundTransformerTest {
Message amqp = AMQPConverter.getInstance().fromCore(outbound.getInnerMessage()).getProtonMessage();
assertNotNull(amqp.getBody());
assertTrue(amqp.getBody() instanceof Data);
assertTrue(((Data) amqp.getBody()).getValue() instanceof Binary);
assertFalse(0 == ((Binary) ((Data) amqp.getBody()).getValue()).getLength());
assertTrue(amqp.getBody() instanceof AmqpValue);
assertTrue(((AmqpValue) amqp.getBody()).getValue() instanceof Binary);
assertFalse(0 == ((Binary) ((AmqpValue) amqp.getBody()).getValue()).getLength());
Object value = deserialize((((Data) amqp.getBody()).getValue()).getArray());
Object value = deserialize(((Binary) ((AmqpValue) amqp.getBody()).getValue()).getArray());
assertNotNull(value);
assertTrue(value instanceof UUID);
}
@ -361,7 +361,7 @@ public class JMSMappingOutboundTransformerTest {
assertNotNull(amqp.getBody());
assertTrue(amqp.getBody() instanceof AmqpValue);
assertTrue(((AmqpValue) amqp.getBody()).getValue() instanceof Binary);
assertEquals(0, ((Binary) ((AmqpValue) amqp.getBody()).getValue()).getLength());
assertEquals(5, ((Binary) ((AmqpValue) amqp.getBody()).getValue()).getLength());
}
// ----- TextMessage type tests -------------------------------------------//