Skip to content
Permalink
Browse files
ARTEMIS-3801 fix test
  • Loading branch information
jbertram committed Apr 26, 2022
1 parent ed5ae2c commit 3339ca8b68b0c347e05f19e5922080351729f64e
Showing 1 changed file with 15 additions and 5 deletions.
@@ -44,8 +44,6 @@

import static io.netty.handler.codec.mqtt.MqttProperties.MqttPropertyType.SUBSCRIPTION_IDENTIFIER;
import static org.apache.activemq.artemis.core.protocol.mqtt.MQTTUtil.DOLLAR;
import static org.apache.activemq.artemis.core.protocol.mqtt.MQTTUtil.HASH;
import static org.apache.activemq.artemis.core.protocol.mqtt.MQTTUtil.PLUS;
import static org.apache.activemq.artemis.core.protocol.mqtt.MQTTUtil.SLASH;
import static org.apache.activemq.artemis.reader.MessageUtil.CONNECTION_ID_PROPERTY_NAME_STRING;

@@ -70,9 +68,16 @@ public class MQTTSubscriptionManager {
*/
private final SimpleString messageFilterNoDollar;

private final char singleWord;

private final char anyWords;

public MQTTSubscriptionManager(MQTTSession session) {
this.session = session;

singleWord = session.getServer().getConfiguration().getWildcardConfiguration().getSingleWord();
anyWords = session.getServer().getConfiguration().getWildcardConfiguration().getAnyWords();

consumers = new ConcurrentHashMap<>();
consumerQoSLevels = new ConcurrentHashMap<>();

@@ -87,9 +92,10 @@ public MQTTSubscriptionManager(MQTTSession session) {
messageFilter.append(")");
this.messageFilter = new SimpleString(messageFilter.toString());

// [MQTT-4.7.2-1]
StringBuilder messageFilterNoDollar = new StringBuilder(baseFilter);
messageFilterNoDollar.append(" OR ");
messageFilterNoDollar.append("(").append(FilterConstants.ACTIVEMQ_ADDRESS).append(" LIKE '").append(DOLLAR).append("%')"); // [MQTT-4.7.2-1]
messageFilterNoDollar.append("(").append(FilterConstants.ACTIVEMQ_ADDRESS).append(" LIKE '").append(DOLLAR).append("%')");
messageFilterNoDollar.append(")");
this.messageFilterNoDollar = new SimpleString(messageFilterNoDollar.toString());
}
@@ -211,8 +217,12 @@ private Queue findOrCreateQueue(BindingQueryResult bindingQueryResult, AddressIn
throw ActiveMQMessageBundle.BUNDLE.invalidRoutingTypeForAddress(addressInfo.getRoutingType(), addressInfo.getName().toString(), EnumSet.allOf(RoutingType.class));
}

private SimpleString getMessageFilter(SimpleString topicFilter) {
if (topicFilter.startsWith(PLUS) || topicFilter.startsWith(HASH)) {
private SimpleString getMessageFilter(SimpleString addressName) {
/*
* By the time we get here wildcards in the MQTT topic filter have already been translated into their core
* equivalents. This check is to enforce [MQTT-4.7.2-1].
*/
if (addressName.startsWith(singleWord) || addressName.startsWith(anyWords)) {
return messageFilterNoDollar;
} else {
return messageFilter;

0 comments on commit 3339ca8

Please sign in to comment.