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 2022/11/10 12:52:49 UTC

[activemq-artemis] branch main updated (9528e45869 -> 42529899d0)

This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


    from 9528e45869 ARTEMIS-4083 ClientLargeMessage Streaming not closing inputStream if compressed
     new f2e0f8713f ARTEMIS-4083 ClientLargeMessage Streaming not closing inputStream if compressed
     new 42529899d0 NO-JIRA small tweak on test

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../core/client/impl/ClientProducerImpl.java       |  3 +-
 .../tests/integration/client/LargeMessageTest.java | 46 ++++++++++++++++------
 .../artemis/tests/unit/util/LinkedListTest.java    |  6 +++
 3 files changed, 42 insertions(+), 13 deletions(-)


[activemq-artemis] 02/02: NO-JIRA small tweak on test

Posted by cl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git

commit 42529899d01df63c4aea5f562a2db8058a455a5e
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Thu Nov 10 07:51:45 2022 -0500

    NO-JIRA small tweak on test
---
 .../org/apache/activemq/artemis/tests/unit/util/LinkedListTest.java | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/LinkedListTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/LinkedListTest.java
index f95e91fc2c..b39a9e75dc 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/LinkedListTest.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/LinkedListTest.java
@@ -108,8 +108,14 @@ public class LinkedListTest extends ActiveMQTestBase {
       Assert.assertEquals(1, scans);
       list.addSorted(10);
       list.addSorted(20);
+      list.addSorted(19);
       list.addSorted(7); // this will need a scan as it's totally random
       Assert.assertEquals(2, scans);
+      list.addSorted(8);
+      Assert.assertEquals(2, scans);
+      Assert.assertEquals(1, (int)list.poll());
+      list.addSorted(9);
+      Assert.assertEquals(3, scans); // remove (poll) should clear the last added cache
       printDebug();
 
       validateOrder(null);


[activemq-artemis] 01/02: ARTEMIS-4083 ClientLargeMessage Streaming not closing inputStream if compressed

Posted by cl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git

commit f2e0f8713fb984c0c9b222a1e44470cff4606cf6
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Thu Nov 10 07:51:30 2022 -0500

    ARTEMIS-4083 ClientLargeMessage Streaming not closing inputStream if compressed
---
 .../core/client/impl/ClientProducerImpl.java       |  3 +-
 .../tests/integration/client/LargeMessageTest.java | 46 ++++++++++++++++------
 2 files changed, 36 insertions(+), 13 deletions(-)

diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerImpl.java
index bdb3a02223..25e5f7a372 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerImpl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerImpl.java
@@ -459,7 +459,8 @@ public class ClientProducerImpl implements ClientProducerInternal {
                }
 
                pos += numberOfBytesRead;
-            } while (pos < minLargeMessageSize);
+            }
+            while (pos < minLargeMessageSize);
 
             totalSize += pos;
 
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LargeMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LargeMessageTest.java
index 2e00436088..b1e96713c5 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LargeMessageTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LargeMessageTest.java
@@ -2795,27 +2795,36 @@ public class LargeMessageTest extends LargeMessageTestBase {
    }
 
    @Test
-   public void testStream() throws Exception {
+   public void testStreamedMessage() throws Exception {
+      testStream(false);
+   }
+
+   @Test
+   public void testStreamedMessageCompressed() throws Exception {
+      testStream(true);
+   }
+
+   private void testStream(boolean compressed) throws Exception {
       ActiveMQServer server = createServer(true, isNetty(), storeType);
 
       server.start();
 
-      locator.setCompressLargeMessage(true);
+      locator.setCompressLargeMessage(compressed);
 
       ClientSessionFactory sf = addSessionFactory(createSessionFactory(locator));
 
       ClientSession session = sf.createSession(false, false);
 
-      final SimpleString MY_QUEUE = new SimpleString("MY-QUEUE");
-
-      server.createQueue(new QueueConfiguration(MY_QUEUE).setRoutingType(RoutingType.ANYCAST));
+      session.createQueue(new QueueConfiguration(ADDRESS));
 
-      ClientProducer producer = session.createProducer(MY_QUEUE);
+      ClientProducer producer = session.createProducer(ADDRESS);
 
       AtomicBoolean closed = new AtomicBoolean(false);
 
+      final int BYTES = 1_000;
+
       InputStream inputStream = new InputStream() {
-         int bytes = 10_000;
+         int bytes = BYTES;
          @Override
          public int read() throws IOException {
             if (bytes-- > 0) {
@@ -2830,12 +2839,10 @@ public class LargeMessageTest extends LargeMessageTestBase {
             closed.set(true);
          }
 
-
          @Override
-         public int available () throws IOException {
+         public int available() {
             return bytes;
          }
-
       };
 
       ClientMessage message = session.createMessage(true);
@@ -2844,11 +2851,26 @@ public class LargeMessageTest extends LargeMessageTestBase {
 
       Wait.assertTrue(closed::get);
 
-      session.close();
+      session.commit();
 
-   }
+      session.start();
+
+      ClientConsumer consumer = session.createConsumer(ADDRESS);
 
+      ClientMessage receivedMessage = consumer.receive(5000);
+      Assert.assertNotNull(receivedMessage);
 
+      ActiveMQBuffer buffer = receivedMessage.getBodyBuffer();
+      Assert.assertEquals(BYTES, buffer.readableBytes());
 
+      for (int i = 0; i < BYTES; i++) {
+         Assert.assertEquals((byte)10, buffer.readByte());
+      }
+
+      Assert.assertEquals(0, buffer.readableBytes());
+
+      session.close();
+
+   }
 
 }
\ No newline at end of file