gemmellr commented on code in PR #4556:
URL: https://github.com/apache/activemq-artemis/pull/4556#discussion_r1267114894
##########
artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTPublishManager.java:
##########
@@ -404,12 +406,15 @@ private boolean publishToClient(int messageId,
ICoreMessage message, int deliver
// [MQTT-3.3.1-2] The DUP flag MUST be set to 0 for all QoS 0 messages.
boolean redelivery = qos == 0 ? false : (deliveryCount > 1);
- boolean isRetain = message.getBooleanProperty(MQTT_MESSAGE_RETAIN_KEY);
+ boolean isRetain =
message.containsProperty(MQTT_MESSAGE_RETAIN_INITIAL_DISTRIBUTION_KEY);
MqttProperties mqttProperties = getPublishProperties(message);
if (session.getVersion() == MQTTVersion.MQTT_5) {
- if (session.getState().getSubscription(message.getAddress()) != null
&&
!session.getState().getSubscription(message.getAddress()).option().isRetainAsPublished())
{
- isRetain = false;
+ if (message.getBooleanProperty(MQTT_MESSAGE_RETAIN_KEY) &&
!message.containsProperty(MQTT_MESSAGE_RETAIN_INITIAL_DISTRIBUTION_KEY)) {
Review Comment:
Since we already know the presence result from the earlier check, and only
need to do the rest if that was false, what about:
```suggestion
if (!isRetain &&
message.getBooleanProperty(MQTT_MESSAGE_RETAIN_KEY)) {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]