ARTEMIS-1505: NPE prevents browsing queue with large messages

This commit is contained in:
saurabhrai 2017-11-27 13:01:04 +05:30 committed by Clebert Suconic
parent 92ce07a584
commit 6315e3faf0
1 changed files with 14 additions and 6 deletions

View File

@ -267,10 +267,14 @@ public final class OpenTypeSupport {
public Map<String, Object> getFields(MessageReference ref) throws OpenDataException {
Map<String, Object> rc = super.getFields(ref);
ICoreMessage m = ref.getMessage().toCore();
ActiveMQBuffer bodyCopy = m.getReadOnlyBodyBuffer();
byte[] bytes = new byte[bodyCopy.readableBytes()];
bodyCopy.readBytes(bytes);
rc.put(CompositeDataConstants.BODY, bytes);
if (!m.isLargeMessage()) {
ActiveMQBuffer bodyCopy = m.getReadOnlyBodyBuffer();
byte[] bytes = new byte[bodyCopy.readableBytes()];
bodyCopy.readBytes(bytes);
rc.put(CompositeDataConstants.BODY, bytes);
} else {
rc.put(CompositeDataConstants.BODY, new byte[0]);
}
return rc;
}
}
@ -288,8 +292,12 @@ public final class OpenTypeSupport {
public Map<String, Object> getFields(MessageReference ref) throws OpenDataException {
Map<String, Object> rc = super.getFields(ref);
ICoreMessage m = ref.getMessage().toCore();
SimpleString text = m.getReadOnlyBodyBuffer().readNullableSimpleString();
rc.put(CompositeDataConstants.TEXT_BODY, text != null ? text.toString() : "");
if (!m.isLargeMessage()) {
SimpleString text = m.getReadOnlyBodyBuffer().readNullableSimpleString();
rc.put(CompositeDataConstants.TEXT_BODY, text != null ? text.toString() : "");
} else {
rc.put(CompositeDataConstants.TEXT_BODY, "");
}
return rc;
}
}