cshannon commented on code in PR #979:
URL: https://github.com/apache/activemq/pull/979#discussion_r1108702198
##########
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:
Thanks, good catch. I just copied this from the parent Message class in its
copy() method:
https://github.com/apache/activemq/blob/ae4e305f850dd35d92f8e49758309f21609d3206/activemq-client/src/main/java/org/apache/activemq/command/Message.java#L184-L189
This makes me wonder if this needs to be fixed there at some point as well.
I've sometimes seen weird behavior with the VM transport that appeared to be
from shared messages between server/client even though copying should be happen
so maybe this is a culprit.
--
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]