activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [activemq-artemis] branch master updated: ARTEMIS-2766 Not parsing application properties for duplicate property
Date Fri, 15 May 2020 20:19:27 GMT
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 8562e6a  ARTEMIS-2766 Not parsing application properties for duplicate property
     new 79fef2f  This closes #3138
8562e6a is described below

commit 8562e6a1a7537736eb3c848e6f4b97e8bf8fb44b
Author: Clebert Suconic <clebertsuconic@apache.org>
AuthorDate: Fri May 15 14:00:09 2020 -0400

    ARTEMIS-2766 Not parsing application properties for duplicate property
---
 .../artemis/protocol/amqp/broker/AMQPMessage.java       | 11 +++++++++++
 .../protocol/amqp/broker/AMQPMessageSymbolSearch.java   | 17 +++++++++++++++--
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
index 6e903a3..6226c6d 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
@@ -116,6 +116,10 @@ public abstract class AMQPMessage extends RefCountMessage implements
org.apache.
       AMQPMessageSymbolSearch.kmpNeedleOf(AMQPMessageSupport.SCHEDULED_DELIVERY_TIME),
       AMQPMessageSymbolSearch.kmpNeedleOf(AMQPMessageSupport.SCHEDULED_DELIVERY_DELAY)};
 
+   private static final KMPNeedle[] DUPLICATE_ID_NEEDLES = new KMPNeedle[] {
+      AMQPMessageSymbolSearch.kmpNeedleOf(org.apache.activemq.artemis.api.core.Message.HDR_DUPLICATE_DETECTION_ID.toString())
+   };
+
    public static final int DEFAULT_MESSAGE_FORMAT = 0;
    public static final int DEFAULT_MESSAGE_PRIORITY = 4;
    public static final int MAX_MESSAGE_PRIORITY = 9;
@@ -1015,6 +1019,13 @@ public abstract class AMQPMessage extends RefCountMessage implements
org.apache.
 
    @Override
    public final Object getDuplicateProperty() {
+
+      if (applicationProperties == null) {
+         if (!AMQPMessageSymbolSearch.anyApplicationProperties(getData(), DUPLICATE_ID_NEEDLES))
{
+            // no need for duplicate-property
+            return null;
+         }
+      }
       return getObjectProperty(org.apache.activemq.artemis.api.core.Message.HDR_DUPLICATE_DETECTION_ID);
    }
 
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessageSymbolSearch.java
b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessageSymbolSearch.java
index 5087634..58dea83 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessageSymbolSearch.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessageSymbolSearch.java
@@ -52,7 +52,20 @@ final class AMQPMessageSymbolSearch {
       return KMPNeedle.of(symbol.toString().getBytes(StandardCharsets.US_ASCII));
    }
 
-   public static boolean anyMessageAnnotations(ReadableBuffer data, KMPNeedle[] needles)
{
+   public static KMPNeedle kmpNeedleOf(String symbol) {
+      return KMPNeedle.of(symbol.getBytes(StandardCharsets.US_ASCII));
+   }
+
+
+   public static boolean anyMessageAnnotations(final ReadableBuffer data, final KMPNeedle[]
needles) {
+      return lookupOnSection(MessageAnnotations.class, data, needles);
+   }
+
+   public static boolean anyApplicationProperties(final ReadableBuffer data, final KMPNeedle[]
needles) {
+      return lookupOnSection(ApplicationProperties.class, data, needles);
+   }
+
+   private static boolean lookupOnSection(final Class section, final ReadableBuffer data,
final KMPNeedle[] needles) {
       DecoderImpl decoder = TLSEncode.getDecoder();
       final int position = data.position();
       decoder.setBuffer(data.rewind());
@@ -61,7 +74,7 @@ final class AMQPMessageSymbolSearch {
             TypeConstructor<?> constructor = decoder.readConstructor();
             final Class<?> typeClass = constructor.getTypeClass();
             if (MSG_BODY_TYPES.containsKey(typeClass)) {
-               if (MessageAnnotations.class.equals(typeClass)) {
+               if (section.equals(typeClass)) {
                   final int start = data.position();
                   constructor.skipValue();
                   final int end = data.position();


Mime
View raw message