You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2017/11/21 14:28:04 UTC

activemq-artemis git commit: ARTEMIS-1514 Fix File open on Large Message

Repository: activemq-artemis
Updated Branches:
  refs/heads/master 3fba3573a -> b27ed5de1


ARTEMIS-1514 Fix File open on Large Message


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/b27ed5de
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/b27ed5de
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/b27ed5de

Branch: refs/heads/master
Commit: b27ed5de16784f57a3f5582919cd378b5ba08263
Parents: 3fba357
Author: Clebert Suconic <cl...@apache.org>
Authored: Tue Nov 21 09:27:27 2017 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Nov 21 09:27:27 2017 -0500

----------------------------------------------------------------------
 .../impl/journal/LargeServerMessageImpl.java      |  1 +
 .../openwire/OpenWireLargeMessageTest.java        | 18 +++++++++++++++---
 2 files changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b27ed5de/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java
index d10f3b8..433031c 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java
@@ -205,6 +205,7 @@ public final class LargeServerMessageImpl extends CoreMessage implements LargeSe
    @Override
    public ActiveMQBuffer getReadOnlyBodyBuffer() {
       try {
+         validateFile();
          file.open();
          int fileSize = (int) file.size();
          ByteBuffer buffer = this.storageManager.largeMessagesFactory.newBuffer(fileSize);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b27ed5de/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/OpenWireLargeMessageTest.java
----------------------------------------------------------------------
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 9535cc5..99dcbdb 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
@@ -64,6 +64,11 @@ public class OpenWireLargeMessageTest extends BasicOpenWireTest {
 
    @Test
    public void testSendReceiveLargeMessage() throws Exception {
+      // Create 1MB Message
+      int size = 1024 * 1024;
+
+      byte[] bytes = new byte[size];
+
       try (Connection connection = factory.createConnection()) {
          connection.start();
 
@@ -72,14 +77,21 @@ public class OpenWireLargeMessageTest extends BasicOpenWireTest {
          MessageProducer producer = session.createProducer(queue);
          producer.setDeliveryMode(DeliveryMode.PERSISTENT);
 
-         // Create 1MB Message
-         int size = 1024 * 1024;
-         byte[] bytes = new byte[size];
          bytes[0] = 1;
 
          BytesMessage message = session.createBytesMessage();
          message.writeBytes(bytes);
          producer.send(message);
+      }
+
+      server.stop();
+      server.start();
+
+      try (Connection connection = factory.createConnection()) {
+         connection.start();
+         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+         Queue queue = session.createQueue(lmAddress.toString());
+
 
          MessageConsumer consumer = session.createConsumer(queue);
          BytesMessage m = (BytesMessage) consumer.receive();