diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java index fd1f7320d5..49d897de58 100644 --- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java +++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java @@ -504,6 +504,15 @@ public final class OpenWireMessageConverter { return md; } + private static final class EagerActiveMQBytesMessage extends ActiveMQBytesMessage { + + EagerActiveMQBytesMessage(int size) { + this.bytesOut = new org.apache.activemq.util.ByteArrayOutputStream(size); + OutputStream os = bytesOut; + this.dataOut = new DataOutputStream(os); + } + } + private static ActiveMQMessage toAMQMessage(MessageReference reference, ICoreMessage coreMessage, WireFormat marshaller, @@ -518,7 +527,7 @@ public final class OpenWireMessageConverter { switch (coreType) { case org.apache.activemq.artemis.api.core.Message.BYTES_TYPE: - amqMsg = new ActiveMQBytesMessage(); + amqMsg = new EagerActiveMQBytesMessage(0); bytes = toAMQMessageBytesType(buffer, isCompressed); break; case org.apache.activemq.artemis.api.core.Message.MAP_TYPE: