Skip to content

Commit

Permalink
Allow to pass -1 to Mqtt5PublishBuilderBase.messageExpiryInterval to …
Browse files Browse the repository at this point in the history
…disable message expiry
  • Loading branch information
SgtSilvio committed Nov 14, 2023
1 parent 9cbf830 commit bb5dee5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ public abstract class MqttPublishBuilder<B extends MqttPublishBuilder<B>> {
}

public @NotNull B messageExpiryInterval(final long messageExpiryInterval) {
this.messageExpiryInterval = Checks.unsignedInt(messageExpiryInterval, "Message expiry interval");
if (messageExpiryInterval == -1) {
this.messageExpiryInterval = MqttPublish.NO_MESSAGE_EXPIRY;
} else {
this.messageExpiryInterval = Checks.unsignedInt(messageExpiryInterval, "Message expiry interval");
}
return self();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public interface Mqtt5ConnectBuilderBase<B extends Mqtt5ConnectBuilderBase<B>> {
/**
* Sets the {@link Mqtt5Connect#getSessionExpiryInterval() session expiry interval} in seconds.
* <p>
* The value must be in the range of an unsigned int: [0, 4_294_967_295].
* The value must be in the range of an unsigned int: [0, 4_294_967_295]. 4_294_967_295 disables session expiry.
*
* @param sessionExpiryInterval the session expiry interval in seconds.
* @return the builder.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ interface Complete<C extends Mqtt5PublishBuilderBase.Complete<C>> extends Mqtt5P
/**
* Sets the {@link Mqtt5Publish#getMessageExpiryInterval() message expiry interval} in seconds.
* <p>
* The value must be in the range of an unsigned int: [0, 4_294_967_295].
* The value must be in the range of an unsigned int: [0, 4_294_967_295] or -1 to disable message expiry.
*
* @param messageExpiryInterval the message expiry interval in seconds.
* @return the builder.
Expand Down

0 comments on commit bb5dee5

Please sign in to comment.