diff --git a/broker/src/main/java/io/moquette/broker/subscriptions/CTrie.java b/broker/src/main/java/io/moquette/broker/subscriptions/CTrie.java index 6143c1a47..b9b525416 100644 --- a/broker/src/main/java/io/moquette/broker/subscriptions/CTrie.java +++ b/broker/src/main/java/io/moquette/broker/subscriptions/CTrie.java @@ -254,12 +254,12 @@ private List recursiveMatch(Topic topicName, INode inode, int dept // type #, + or exact match Optional subInode = cnode.childOf(Token.MULTI); if (subInode.isPresent()) { - Topic remainingRealTopic = (ROOT.equals(cnode.getToken())) ? topicName : topicName.exceptFullHeadToken(); subscriptions.addAll(recursiveMatch(remainingTopic, subInode.get(), depth + 1)); } subInode = cnode.childOf(Token.SINGLE); if (subInode.isPresent()) { - subscriptions.addAll(recursiveMatch(remainingTopic, subInode.get(), depth + 1)); + Topic remainingRealTopic = (ROOT.equals(cnode.getToken())) ? topicName : topicName.exceptFullHeadToken(); + subscriptions.addAll(recursiveMatch(remainingRealTopic, subInode.get(), depth + 1)); } if (remainingTopic.isEmpty()) { subscriptions.addAll(cnode.sharedAndNonSharedSubscriptions());