Description
TopicRepository.add(topic, message) is called unconditionally for every inbound PUBLISH regardless of the retain bit (module-wide grep for isRetain/retain returns zero hits). A zero-byte retained PUBLISH should delete the retained message — that never happens.
Location
shenyu-protocol/shenyu-protocol-mqtt/src/main/java/org/apache/shenyu/protocol/mqtt/Publish.java:55
shenyu-protocol/shenyu-protocol-mqtt/src/main/java/org/apache/shenyu/protocol/mqtt/repositories/TopicRepository.java:34-37
Impact
Non-retained messages are persisted and redelivered to future subscribers as if they were retained (via Subscribe.sendSubMessage at Subscribe.java:72-77, which sends with retain=true). Violates MQTT-3.3.1.
Suggested fix
Read msg.fixedHeader().isRetain(); only call TopicRepository.add when retain is true; on a zero-byte retained PUBLISH, call TopicRepository.remove(topic).
Description
TopicRepository.add(topic, message)is called unconditionally for every inbound PUBLISH regardless of the retain bit (module-wide grep forisRetain/retainreturns zero hits). A zero-byte retained PUBLISH should delete the retained message — that never happens.Location
shenyu-protocol/shenyu-protocol-mqtt/src/main/java/org/apache/shenyu/protocol/mqtt/Publish.java:55shenyu-protocol/shenyu-protocol-mqtt/src/main/java/org/apache/shenyu/protocol/mqtt/repositories/TopicRepository.java:34-37Impact
Non-retained messages are persisted and redelivered to future subscribers as if they were retained (via
Subscribe.sendSubMessageatSubscribe.java:72-77, which sends withretain=true). Violates MQTT-3.3.1.Suggested fix
Read
msg.fixedHeader().isRetain(); only callTopicRepository.addwhen retain is true; on a zero-byte retained PUBLISH, callTopicRepository.remove(topic).