@@ -53,7 +53,7 @@ public class MqttPublish extends MqttMessageWithUserProperties implements Mqtt5P
53
53
public static final long NO_MESSAGE_EXPIRY = -1 ;
54
54
55
55
private final @ NotNull MqttTopicImpl topic ;
56
- private final @ Nullable ByteBuffer payload ;
56
+ private final @ NotNull ByteBuffer payload ;
57
57
private final @ NotNull MqttQos qos ;
58
58
private final boolean retain ;
59
59
private final @ Range (from = -1 , to = UnsignedDataTypes .UNSIGNED_INT_MAX_VALUE ) long messageExpiryInterval ;
@@ -66,7 +66,7 @@ public class MqttPublish extends MqttMessageWithUserProperties implements Mqtt5P
66
66
67
67
public MqttPublish (
68
68
final @ NotNull MqttTopicImpl topic ,
69
- final @ Nullable ByteBuffer payload ,
69
+ final @ NotNull ByteBuffer payload ,
70
70
final @ NotNull MqttQos qos ,
71
71
final boolean retain ,
72
72
final @ Range (from = -1 , to = UnsignedDataTypes .UNSIGNED_INT_MAX_VALUE ) long messageExpiryInterval ,
@@ -96,11 +96,11 @@ public MqttPublish(
96
96
}
97
97
98
98
@ Override
99
- public @ NotNull Optional < ByteBuffer > getPayload () {
100
- return ByteBufferUtil . optionalReadOnly ( payload );
99
+ public @ NotNull ByteBuffer getPayload () {
100
+ return payload . asReadOnlyBuffer ( );
101
101
}
102
102
103
- public @ Nullable ByteBuffer getRawPayload () {
103
+ public @ NotNull ByteBuffer getRawPayload () {
104
104
return payload ;
105
105
}
106
106
@@ -211,13 +211,12 @@ public void acknowledge() {
211
211
212
212
@ Override
213
213
protected @ NotNull String toAttributeString () {
214
- return "topic=" + topic + ((payload == null ) ? "" : ", payload=" + payload .remaining () + "byte" ) + ", qos=" +
215
- qos + ", retain=" + retain + ((messageExpiryInterval == NO_MESSAGE_EXPIRY ) ? "" :
216
- ", messageExpiryInterval=" + messageExpiryInterval ) +
217
- ((payloadFormatIndicator == null ) ? "" : ", payloadFormatIndicator=" + payloadFormatIndicator ) +
218
- ((contentType == null ) ? "" : ", contentType=" + contentType ) +
219
- ((responseTopic == null ) ? "" : ", responseTopic=" + responseTopic ) +
220
- ((correlationData == null ) ? "" : ", correlationData=" + correlationData .remaining () + "byte" ) +
214
+ return "topic=" + topic + ", payload=" + payload .remaining () + "byte" + ", qos=" + qos + ", retain=" + retain +
215
+ (messageExpiryInterval == NO_MESSAGE_EXPIRY ? "" : ", messageExpiryInterval=" + messageExpiryInterval ) +
216
+ (payloadFormatIndicator == null ? "" : ", payloadFormatIndicator=" + payloadFormatIndicator ) +
217
+ (contentType == null ? "" : ", contentType=" + contentType ) +
218
+ (responseTopic == null ? "" : ", responseTopic=" + responseTopic ) +
219
+ (correlationData == null ? "" : ", correlationData=" + correlationData .remaining () + "byte" ) +
221
220
StringUtil .prepend (", " , super .toAttributeString ());
222
221
}
223
222
0 commit comments