Repository navigation
fix(binding-mqtt-kafka): guard expiry signal when the kafka session stream is not established - #3138
Merged
Merged
Conversation
…tream is established Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoTc8VafVZ1K6X9hSwi
…tream is not established Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoTc8VafVZ1K6X9hSwi
…ministic The MQTT reply stream is never begun for a qos2 session that ends before the session stream is established, so its throttle stays registered until the kafka meta streams abort and the proxy aborts the MQTT reply. Without that abort being part of the scenario, engine close could win the race and deliver its synthetic reset (sequence Long.MAX_VALUE) to onMqttReset, failing its sequence assertion. Kafka now aborts the meta streams after the proxy ends them and the MQTT client reads the resulting abort, so the scenario completes only after the proxy has torn down the MQTT reply. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoTc8VafVZ1K6X9hSwi
This was referenced Nov 12, 2026
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
An MQTT client that connects and then disconnects while the Kafka session stream was never established terminated an engine worker with a
NullPointerException:The exception escaped
EngineWorker.doWork, so the worker thread was lost.Cause
On the QoS 2 path without a Will flag,
doEstablishSessionopens the meta streams but never begins theKafkaSessionStream, so itskafkareceiver stays null.onMqttEndandonMqttAbortthen callsendExpirySignal, which wrote to the missing receiver.Change
KafkaSessionStreamnow checksisKafkaOpen()(the receiver exists, the initial side is opening and not closed, derived from the existingStreamStatebitmask, with no new fields) before the threedoKafkaDatavariants anddoKafkaFlush. This coverssendExpirySignal,cancelExpirySignal, the will-signal sends and the data forwarded from the MQTT side, since all go through those helpers.The
doKafkaDataanddoKafkaBeginhelpers of the meta, offset-fetch, init-producer and offset-commit streams were checked and left unchanged: they are only reached from window or data callbacks on streams that already have a Kafka stream.Fixes #3120
Tests
Written first. A paired
client.rpt/server.rptscenariosession.qos2.end.before.session.established(MQTT side and Kafka side) covers "the MQTT client connects, the Kafka session stream is not established, the MQTT client ends", with a spec-level method inMqttITandKafkaITandshouldEndQos2SessionBeforeSessionStreamEstablishedin the existingMqttKafkaSessionProxyIT. No new IT class.Before the fix the runtime IT failed with the NPE above (
receiver is null, worker terminated). The spec-level ITs passed before the fix, because they exercise only the protocol scripts.Run in the session that wrote the change, with checkstyle and license checks:
specs/binding-mqtt-kafka.specwith the build cache bypassed: 27 unit tests,MqttIT93,KafkaIT118, 0 failures.runtime/binding-mqtt-kafka: 10 unit tests,MqttKafkaSessionProxyIT28,MqttKafkaPublishProxyIT39,MqttKafkaSubscribeProxyIT55, 0 failures.Not run: the manual
zilla startreproduction from the issue; the k3po runtime IT is the equivalent.Notes and follow-ups (not changed here)
KafkaSessionStream.onKafkaResetdoes not mark the initial side closed instate, so a stream reset by Kafka is not caught by the!initialClosedpart of the guard. Thekafka != nulland opening checks still apply.doKafkaEndanddoKafkaAborthelpers of the meta streams rely on akafka != nullcheck only.MqttKafkaSessionFactory, so expect small rebase conflicts.Generated by Claude Code