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);