Closed skobow closed 10 months ago
This is actually intended. The builder only allows to set values according to the MQTT specification. The message expiry interval is a four byte integer and there is no value for no expiry; instead, the message does not expire if the value is completely absent. (Link to the specification: https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901064)
MqttPublish.NO_MESSAGE_EXPIRY
is only the value that this library uses internally to represent an absent value.
Also, MqttPublish
is an internal class, so should not be used at all.
As this is intended behavior, I will remove the bug label. If you really need this, we can discuss making an improvement out of it.
🐛 Bug Report
It is currently not possible to publish a message using
MqttPublishBuilder.messageExpiryInterval(MqttPublish.NO_MESSAGE_EXPIRY)
to disable message expiry instead of usingMqttPublishBuilder.noMessageExpiry()
as there is an invalid guard condition checking for the correct value range. As the message expiry interval is andunsigned Long
value the guard condition checks forunsigned Integer
instead causing the check to fail.🔬 How To Reproduce
See code sample.
Code sample
Environment
irrelevant
Screenshots
📈 Expected behavior
Being able to use
MqttPublish.NO_MESSAGE_EXPIRY
withMqttPublishBuilder.messageExpiryInterval()
.📎 Additional context
The builder itself is bypassing the guard condition when using
MqttPublishBuilder.noMessageExpiry()
.