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/05/16 15:40:19 UTC
[activemq-artemis] 02/03: ARTEMIS-2766 Improving
AMQPMessageSymbolSearch for correctness
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
commit 1420ad77453b0d1cfd9a1944716fd2c665423635
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Sat May 16 01:33:32 2020 -0400
ARTEMIS-2766 Improving AMQPMessageSymbolSearch for correctness
---
.RELEASING.md.swp | Bin 16384 -> 0 bytes
.../amqp/broker/AMQPMessageSymbolSearch.java | 27 +++++++++++++--------
2 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/.RELEASING.md.swp b/.RELEASING.md.swp
deleted file mode 100644
index 9e08875..0000000
Binary files a/.RELEASING.md.swp and /dev/null differ
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 71b9880..eaf05ca 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
@@ -37,15 +37,22 @@ import org.apache.qpid.proton.codec.TypeConstructor;
final class AMQPMessageSymbolSearch {
// used to quick search for MessageAnnotations
- private static final IdentityHashMap<Class<?>, Boolean> MSG_BODY_TYPES;
+ private static final IdentityHashMap<Class<?>, Boolean> MSG_ANNOTATIONS_STOPSET;
+ private static final IdentityHashMap<Class<?>, Boolean> APPLICATION_PROPERTIES_STOPSET;
static {
// we're including MessageAnnotations here because it will still cause termination
- final List<Class<?>> classList = Arrays.asList(MessageAnnotations.class, Properties.class,
- ApplicationProperties.class, Data.class,
- AmqpSequence.class, AmqpValue.class, Footer.class);
- MSG_BODY_TYPES = new IdentityHashMap<>(classList.size());
- classList.forEach(clazz -> MSG_BODY_TYPES.put(clazz, Boolean.TRUE));
+ List<Class<?>> classList = Arrays.asList(MessageAnnotations.class, Properties.class,
+ ApplicationProperties.class, Data.class,
+ AmqpSequence.class, AmqpValue.class, Footer.class);
+ MSG_ANNOTATIONS_STOPSET = new IdentityHashMap<>(classList.size());
+ classList.forEach(clazz -> MSG_ANNOTATIONS_STOPSET.put(clazz, Boolean.TRUE));
+
+ // we're including ApplicationProperties here because it will still cause termination
+ classList = Arrays.asList(ApplicationProperties.class, Data.class,
+ AmqpSequence.class, AmqpValue.class, Footer.class);
+ APPLICATION_PROPERTIES_STOPSET = new IdentityHashMap<>(classList.size());
+ classList.forEach(clazz -> APPLICATION_PROPERTIES_STOPSET.put(clazz, Boolean.TRUE));
}
public static KMPNeedle kmpNeedleOf(Symbol symbol) {
@@ -58,14 +65,14 @@ final class AMQPMessageSymbolSearch {
public static boolean anyMessageAnnotations(final ReadableBuffer data, final KMPNeedle[] needles) {
- return lookupOnSection(MessageAnnotations.class, data, needles, 0);
+ return lookupOnSection(MSG_ANNOTATIONS_STOPSET, MessageAnnotations.class, data, needles, 0);
}
public static boolean anyApplicationProperties(final ReadableBuffer data, final KMPNeedle[] needles, int startAt) {
- return lookupOnSection(ApplicationProperties.class, data, needles, startAt);
+ return lookupOnSection(APPLICATION_PROPERTIES_STOPSET, ApplicationProperties.class, data, needles, startAt);
}
- private static boolean lookupOnSection(final Class section, final ReadableBuffer data, final KMPNeedle[] needles, final int startAt) {
+ private static boolean lookupOnSection(IdentityHashMap<Class<?>, Boolean> stopSet, final Class section, final ReadableBuffer data, final KMPNeedle[] needles, final int startAt) {
DecoderImpl decoder = TLSEncode.getDecoder();
final int position = data.position();
decoder.setBuffer(data.position(startAt));
@@ -73,7 +80,7 @@ final class AMQPMessageSymbolSearch {
while (data.hasRemaining()) {
TypeConstructor<?> constructor = decoder.readConstructor();
final Class<?> typeClass = constructor.getTypeClass();
- if (MSG_BODY_TYPES.containsKey(typeClass)) {
+ if (MSG_ANNOTATIONS_STOPSET.containsKey(typeClass)) {
if (section.equals(typeClass)) {
final int start = data.position();
constructor.skipValue();