For example when i subscribe to foo/+/bar/# and publish on foo/something/bar
-> if (topicName.charAt(topicPos - 1) == '/' && topicFilter.charAt(filterPos) == '#')
this returns false, because the topicFilter at filterPos is / and not #
-> if (topicFilter.length() - filterPos > 1 && topicFilter.substring(filterPos, filterPos + 2).equals("/#"))
returns false, because topicFilter length - filterPos is exactly 1
-> if ((topicFilter.length() - topicName.length()) == 2 && topicFilter.substring(topicFilter.length() - 2, topicFilter.length()).equals("/#"))
returns false, because topicFilter length - topicName length is negative the length of the word that replaces the single level wildcard plus 3 ( 1 for the single level wildcard and 2 for the /#)
[ ] Bug exists Release Version 1.2.5 ( Master Branch)
[ ] Bug exists in MQTTv3 Client on Snapshot Version 1.2.6-SNAPSHOT (Develop Branch)
[ ] Bug exists in MQTTv5 Client on Snapshot Version 1.2.6-SNAPSHOT (Develop Branch)
In the case that there is a single level wildcard somewhere in the topic the fixes provided by https://github.com/eclipse/paho.mqtt.java/issues/418 won't work
For example when i subscribe to foo/+/bar/# and publish on foo/something/bar
-> if (topicName.charAt(topicPos - 1) == '/' && topicFilter.charAt(filterPos) == '#') this returns false, because the topicFilter at filterPos is / and not #
-> if (topicFilter.length() - filterPos > 1 && topicFilter.substring(filterPos, filterPos + 2).equals("/#")) returns false, because topicFilter length - filterPos is exactly 1
-> if ((topicFilter.length() - topicName.length()) == 2 && topicFilter.substring(topicFilter.length() - 2, topicFilter.length()).equals("/#")) returns false, because topicFilter length - topicName length is negative the length of the word that replaces the single level wildcard plus 3 ( 1 for the single level wildcard and 2 for the /#)