Repository navigation
fix(binding-mqtt-kafka): keep a trailing empty topic level when splitting topic names and filters - #3274
Merged
jfallows merged 5 commits intoNov 17, 2026
Conversation
…sh and subscribe A topic name or filter ending in a topic level separator has a trailing zero-length topic level (MQTT 5.0 4.7.1.1, MQTT 3.1.1 4.7.1.1), so "sensor/" and "sensor" are different topics. Add script pairs and proxy ITs where a publish to "sensor/" and a subscription to "sensor/" carry the empty level in the Kafka filter headers. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoXYN9cNKpG48feM66S
…ting topic names and filters
String.split("/") drops trailing empty strings, so "sensor/" was published and
subscribed as "sensor". Split with a negative limit so each topic level, including
a trailing zero-length one, becomes a Kafka filter header value (MQTT 5.0 4.7.1.1,
MQTT 3.1.1 4.7.1.1). This matches how the reply-filter header already keeps the
trailing level.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SiHVoXYN9cNKpG48feM66S
…l message topic The will message topic is delivered to Kafka with one filter header per topic level, so a will topic ending in a topic level separator must carry the trailing zero-length level (MQTT 5.0 4.7.1.1, MQTT 3.1.1 4.7.1.1). Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoXYN9cNKpG48feM66S
…l message topic Split the will message topic with a negative limit so a trailing zero-length topic level becomes a filter header value, as for published topics and subscribed filters (MQTT 5.0 4.7.1.1, MQTT 3.1.1 4.7.1.1). Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoXYN9cNKpG48feM66S
…qos-max' into fix/3260-mqtt-kafka-trailing-empty-level
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Both the publish and the subscribe side of mqtt-kafka split topics with
String.split("/"), which drops a trailing empty string. A topicsensor/was therefore published with the Kafka filter headers[sensor], and a filtersensor/was subscribed as[sensor]. As a result a subscriber ofsensorcould receive the topicsensor/, and a filtersensor/+([sensor, skip]) could never match it. The will message topic is split the same way.The change splits with a negative limit (
split("/", -1)) inMqttKafkaPublishFactory(topic name headers),MqttKafkaSubscribeFactory(buildHeaders) andMqttKafkaSessionFactory(will message topic headers), so every level, including a trailing zero-length one, becomes a filter header value. This mirrors how the same binding already keeps the trailing level in the reply-filter header (MqttKafkaPublishFactory.addFiltersHeader) and inMqttKafkaConditionMatcher, which splits with a positive limit.This PR is stacked on #3273 (base
fix/3205-mqtt-kafka-clean-start-qos-max).Other splits of topic strings in the binding
Searched
split(inruntime/binding-mqtt-kafka/src/mainandruntime/binding-mqtt/src/main:MqttKafkaPublishFactory(topic name),MqttKafkaSubscribeFactory(filter),MqttKafkaSessionFactory(will topic).MqttKafkaConditionMatcher(split("/", 2)), the reply-filter header loops inMqttKafkaPublishFactoryandMqttKafkaSessionFactory(indexOfBytebased).split("::")calls that parse configured method names inMqttKafkaConfigurationandMqttConfiguration.Specification statements (read from the OASIS text)
Read in full: 4.7.1.1 to 4.7.1.3 of both texts, and the start of 4.7.2. Not read: the rest of Chapter 4, and the Kafka protocol documentation (the header matching involved is internal to the Zilla Kafka cache).
Test evidence
publish.topic.trailing.empty.level,subscribe.topic.filter.trailing.empty.levelandsession.will.message.topic.trailing.empty.level(mqtt and kafka sides), with methods in the existingMqttIT,KafkaIT,MqttKafkaPublishProxyIT,MqttKafkaSubscribeProxyITandMqttKafkaSessionProxyIT. No new IT classes.verifyunder a 600 s timeout against the unfixed code, the three new proxy ITs fail because the Kafkazilla:filterheaders lack the trailing empty value, whileshouldSendOneMessage,shouldFilterSingleLevelWildcardandshouldSendWillMessageOnAbortpass.specs/binding-mqtt-kafka.spec(clean verify, module checks on, 299 tests inMqttITandKafkaIT) andruntime/binding-mqtt-kafka(clean verify, module checks on, 172 integration tests) pass, and the new methods ran in both.subscribe.topic.filter.single.level.wildcardscript already expected[sensor, skip]forsensor/+and passes before and after, so thesensor/+half of the issue is the publish side losing the trailing level.Not delivered
sensor/, deliver to a subscriber ofsensororsensor/+); the ITs assert the headers the binding emits./is covered by the same change but has no dedicated script.buildmodule, unrelated to this change); the touched modules were rebuilt and verified as described above.Fixes #3260
🤖 Generated with Claude Code
https://claude.ai/code/session_01SiHVoXYN9cNKpG48feM66S