diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java index a2f4719925..781334192c 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java @@ -32,6 +32,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicLong; import org.apache.activemq.artemis.Closeable; +import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQIOErrorException; import org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException; @@ -1315,7 +1316,9 @@ public class ServerSessionImpl implements ServerSession, FailureListener { ICoreMessage coreMessage = message.toCore(); LargeServerMessage lsm = getStorageManager().createLargeMessage(storageManager.generateID(), coreMessage); - byte[] body = coreMessage.getReadOnlyBodyBuffer().toByteBuffer().array(); + ActiveMQBuffer buffer = coreMessage.getReadOnlyBodyBuffer(); + byte[] body = new byte[buffer.readableBytes()]; + buffer.readBytes(body); lsm.addBytes(body); lsm.releaseResources(); lsm.putLongProperty(Message.HDR_LARGE_BODY_SIZE, body.length); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/OpenWireLargeMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/OpenWireLargeMessageTest.java index 1219d31050..35cea1befd 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/OpenWireLargeMessageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/OpenWireLargeMessageTest.java @@ -52,8 +52,8 @@ public class OpenWireLargeMessageTest extends BasicOpenWireTest { MessageProducer producer = session.createProducer(queue); producer.setDeliveryMode(DeliveryMode.PERSISTENT); - // Create 100Mb Message - int size = 1024 * 1024 * 10; + // Create 1MB Message + int size = 1024 * 1024; byte[] bytes = new byte[size]; BytesMessage message = session.createBytesMessage(); message.writeBytes(bytes);