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


The following commit(s) were added to refs/heads/main by this push:
     new 2f5463c960 ARTEMIS-4309 Read all bytes of compressed objmsg
2f5463c960 is described below

commit 2f5463c960f5498bb407d38b2a771a7ffdae2504
Author: Peter Brady <peterbrad...@outlook.com>
AuthorDate: Sun May 28 09:39:06 2023 -0400

    ARTEMIS-4309 Read all bytes of compressed objmsg
    
    Continually read from the compressed byte[] into
    the decompressed object
    
    Add test to validate large (>1024 bytes) compressed data can be
    deserialized properly
---
 .../openwire/OpenWireMessageConverter.java         |  2 +-
 .../openwire/interop/CompressedInteropTest.java    | 23 ++++++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)

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 182c7d832f..04d40ff9dd 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
@@ -267,7 +267,7 @@ public final class OpenWireMessageConverter {
          int n = ois.read(buf);
          while (n != -1) {
             decompressed.write(buf, 0, n);
-            n = ois.read();
+            n = ois.read(buf);
          }
          //read done
          return decompressed.toByteSequence();
diff --git 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/interop/CompressedInteropTest.java
 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/interop/CompressedInteropTest.java
index 196660924c..5854ffa095 100644
--- 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/interop/CompressedInteropTest.java
+++ 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/interop/CompressedInteropTest.java
@@ -38,6 +38,7 @@ import org.junit.Test;
 public class CompressedInteropTest extends BasicOpenWireTest {
 
    private static final String TEXT;
+   private static final String LARGE_TEXT;
 
    static {
       StringBuilder builder = new StringBuilder();
@@ -46,6 +47,7 @@ public class CompressedInteropTest extends BasicOpenWireTest {
          builder.append("The quick red fox jumped over the lazy brown dog. ");
       }
       TEXT = builder.toString();
+      LARGE_TEXT = TEXT + TEXT + TEXT + TEXT + TEXT;
    }
 
    @Before
@@ -90,6 +92,9 @@ public class CompressedInteropTest extends BasicOpenWireTest {
       //ObjectMessage
       sendCompressedObjectMessageUsingOpenWire();
       receiveObjectMessage(useCore);
+      //Large ObjectMessage
+      sendCompressedLargeObjectMessageUsingOpenWire();
+      receiveLargeObjectMessage(useCore);
    }
 
    private void sendCompressedStreamMessageUsingOpenWire() throws Exception {
@@ -164,6 +169,24 @@ public class CompressedInteropTest extends 
BasicOpenWireTest {
       assertEquals(TEXT, objectVal);
    }
 
+   private void sendCompressedLargeObjectMessageUsingOpenWire() throws 
Exception {
+      Session session = connection.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
+      ActiveMQDestination destination = createDestination(session, 
ActiveMQDestination.QUEUE_TYPE);
+
+      final ActiveMQMessageProducer producer = (ActiveMQMessageProducer) 
session.createProducer(destination);
+
+      ObjectMessage objectMessage = session.createObjectMessage();
+      objectMessage.setObject(LARGE_TEXT);
+
+      producer.send(objectMessage);
+   }
+
+   private void receiveLargeObjectMessage(boolean useCore) throws Exception {
+      ObjectMessage objectMessage = (ObjectMessage) receiveMessage(useCore);
+      Object objectVal = objectMessage.getObject();
+      assertEquals(LARGE_TEXT, objectVal);
+   }
+
    private void sendCompressedMapMessageUsingOpenWire() throws Exception {
       Session session = connection.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
       ActiveMQDestination destination = createDestination(session, 
ActiveMQDestination.QUEUE_TYPE);

Reply via email to