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 2020/03/24 19:51:58 UTC
[activemq-artemis] branch master updated: ARTEMIS-1975 Fixing
encodesize cached on AMQP Large Message
This is an automated email from the ASF dual-hosted git repository.
clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
The following commit(s) were added to refs/heads/master by this push:
new 31c945f ARTEMIS-1975 Fixing encodesize cached on AMQP Large Message
31c945f is described below
commit 31c945f8b0e1edb98ec1a7af25b1db1407861c47
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Tue Mar 24 15:47:23 2020 -0400
ARTEMIS-1975 Fixing encodesize cached on AMQP Large Message
Encoding ahead is broken with AMQP Large Message
This is still part of ARTEMIS-1975
---
.../core/journal/impl/dataformat/JournalAddRecordTX.java | 14 +++++++++++---
.../largemessages/SimpleStreamingLargeMessageTest.java | 11 ++++++++---
2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/dataformat/JournalAddRecordTX.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/dataformat/JournalAddRecordTX.java
index 483418f..eff5fbf 100644
--- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/dataformat/JournalAddRecordTX.java
+++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/dataformat/JournalAddRecordTX.java
@@ -75,17 +75,25 @@ public class JournalAddRecordTX extends JournalInternalRecord {
buffer.writeLong(id);
- buffer.writeInt(persister.getEncodeSize(record));
+ int persisterEncodeSize = persister.getEncodeSize(record);
+ int encodeSize = getInternalEncodeSize(persisterEncodeSize);
+
+ buffer.writeInt(persisterEncodeSize);
buffer.writeByte(recordType);
persister.encode(buffer, record);
- buffer.writeInt(getEncodeSize());
+ // AMQP Persister may save encoding between getEcodeSize and .encode(). After encode it may release the encoding
+ buffer.writeInt(encodeSize);
}
@Override
public int getEncodeSize() {
- return JournalImpl.SIZE_ADD_RECORD_TX + persister.getEncodeSize(record) + 1;
+ return getInternalEncodeSize(persister.getEncodeSize(record));
+ }
+
+ private int getInternalEncodeSize(int persisterEncodeSize) {
+ return JournalImpl.SIZE_ADD_RECORD_TX + persisterEncodeSize + 1;
}
}
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/largemessages/SimpleStreamingLargeMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/largemessages/SimpleStreamingLargeMessageTest.java
index b54ad8b..c749326 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/largemessages/SimpleStreamingLargeMessageTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/largemessages/SimpleStreamingLargeMessageTest.java
@@ -181,7 +181,7 @@ public class SimpleStreamingLargeMessageTest extends AmqpClientTestSupport {
@Test
public void testSendWithPropertiesNonPersistent() throws Exception {
- testSendWithPropertiesAndFilter(true, false);
+ testSendWithPropertiesAndFilter(true, true);
}
@@ -204,10 +204,16 @@ public class SimpleStreamingLargeMessageTest extends AmqpClientTestSupport {
assertEquals(0, queueView.getMessageCount());
session.begin();
+ int oddID = 0;
for (int m = 0; m < 10; m++) {
AmqpMessage message = new AmqpMessage();
message.setDurable(persistent);
- message.setApplicationProperty("odd", (m % 2 == 0));
+ boolean odd = (m % 2 == 0);
+ message.setApplicationProperty("odd", odd);
+ if (odd) {
+ message.setApplicationProperty("oddID", oddID++);
+ }
+
byte[] bytes = new byte[size];
for (int i = 0; i < bytes.length; i++) {
bytes[i] = (byte) 'z';
@@ -286,7 +292,6 @@ public class SimpleStreamingLargeMessageTest extends AmqpClientTestSupport {
jmsTest(persistent, tx);
}
-
@Test
public void testJMSNonPersistentTX() throws Exception {