jbertram commented on code in PR #4556:
URL: https://github.com/apache/activemq-artemis/pull/4556#discussion_r1267222798


##########
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:
   I considered doing that, but it didn't seem as clear as I wanted it to be at 
the time. Taking another look I think it's fine.



-- 
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]

Reply via email to