mattrpav commented on code in PR #979:
URL: https://github.com/apache/activemq/pull/979#discussion_r1108737642
##########
activemq-client/src/main/java/org/apache/activemq/command/ActiveMQBytesMessage.java:
##########
@@ -956,4 +956,22 @@ protected void doCompress() throws IOException {
}
}
}
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public boolean isBodyAssignableTo(Class c) {
+ return getContent() == null || c.isAssignableFrom(byte[].class);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected <T> T doGetBody(Class<T> asType) {
+ //Make sure the bytes are stored before trying to copy and return
+ if (dataOut != null && getContent() == null) {
+ storeContent();
+ }
+
+ final ByteSequence content = getContent();
+ return content != null ? (T) new ByteSequence(content.getData(),
content.getOffset(),
+ content.getLength()).getData() : null;
Review Comment:
Is using the readBytes() an option here?
```
@Override
public <T> T getBody(Class<T> c) throws JMSException {
if(c == null || getContent() == null) { return null; }
byte[] tmpBytes = new byte[(int)getBodyLength()];
readBytes(tmpBytes);
return (T)tmpBytes;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]