ARTEMIS-4268 AMQPMessage copy constructor shouldn't copy all message annotations

During redistribution, we should not copy all message annotations.

In particular we should not copy any of the x-opt-ORIG annotations used on DLQ and other copies.

this was broken after f632e8104b (ARTEMIS-3833 Preserve JMSCorrelationID of distributed AMQP large messages)

The change preserved too much, and as a result of that AmqpLargeMessageRedistributionTest::testSendMessageToBroker0GetFromBroker2 is intermittently failing.

There is no test in this commit as this is fixing AmqpLargeMessageRedistributionTest
This commit is contained in:
Clebert Suconic 2023-05-01 16:13:26 -04:00 committed by clebertsuconic
parent 0c80a6435f
commit 589157ca5f
1 changed files with 15 additions and 1 deletions

View File

@ -252,7 +252,7 @@ public abstract class AMQPMessage extends RefCountMessage implements org.apache.
this.encodedDeliveryAnnotationsSize = copy.encodedDeliveryAnnotationsSize;
this.deliveryAnnotations = copy.deliveryAnnotations == null ? null : new DeliveryAnnotations(copy.deliveryAnnotations.getValue());
this.messageAnnotationsPosition = copy.messageAnnotationsPosition;
this.messageAnnotations = copy.messageAnnotations == null ? null : new MessageAnnotations(copy.messageAnnotations.getValue());
this.messageAnnotations = copyAnnotations(copy.messageAnnotations);
this.propertiesPosition = copy.propertiesPosition;
this.properties = copy.properties == null ? null : new Properties(copy.properties);
this.applicationPropertiesPosition = copy.applicationPropertiesPosition;
@ -261,6 +261,20 @@ public abstract class AMQPMessage extends RefCountMessage implements org.apache.
this.messageDataScanned = copy.messageDataScanned;
}
private static MessageAnnotations copyAnnotations(MessageAnnotations messageAnnotations) {
if (messageAnnotations == null) {
return null;
}
HashMap newAnnotation = new HashMap();
messageAnnotations.getValue().forEach((a, b) -> {
// These properties should not be copied when re-routing the messages
if (!a.toString().startsWith("x-opt-ORIG") && !a.toString().equals("x-opt-routing-type")) {
newAnnotation.put(a, b);
}
});
return new MessageAnnotations(newAnnotation);
}
protected AMQPMessage(long messageFormat) {
this.messageFormat = messageFormat;
this.coreMessageObjectPools = null;