- 
                Notifications
    
You must be signed in to change notification settings  - Fork 42
 
Fix Subscribe QoS encode and UnsubAck decode. #1152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
| 
     | 
||
| ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.stream.connectors.mqtt.streaming.ControlPacketFlags.ReservedUnsubAck") | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| 
          
            
          
           | 
    @@ -66,7 +66,6 @@ object ControlPacketFlags { | |||||
| val ReservedPubRel = ControlPacketFlags(1 << 1) | ||||||
| val ReservedSubscribe = ControlPacketFlags(1 << 1) | ||||||
| val ReservedUnsubscribe = ControlPacketFlags(1 << 1) | ||||||
| val ReservedUnsubAck = ControlPacketFlags(1 << 1) | ||||||
| val DUP = ControlPacketFlags(1 << 3) | ||||||
| val QoSAtMostOnceDelivery = ControlPacketFlags(0) | ||||||
| val QoSAtLeastOnceDelivery = ControlPacketFlags(1 << 1) | ||||||
| 
          
            
          
           | 
    @@ -456,7 +455,7 @@ final case class Unsubscribe @InternalApi private[streaming] (packetId: PacketId | |||||
| * http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html | ||||||
| */ | ||||||
| final case class UnsubAck(packetId: PacketId) | ||||||
| extends ControlPacket(ControlPacketType.UNSUBACK, ControlPacketFlags.ReservedUnsubAck) | ||||||
| extends ControlPacket(ControlPacketType.UNSUBACK, ControlPacketFlags.ReservedGeneral) | ||||||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.  | 
||||||
| 
     | 
||||||
| /** | ||||||
| * 3.12 PINGREQ – PING request | ||||||
| 
          
            
          
           | 
    @@ -712,7 +711,7 @@ object MqttCodec { | |||||
| v.topicFilters.foreach { | ||||||
| case (topicFilter, topicFilterFlags) => | ||||||
| topicFilter.encode(packetBsb) | ||||||
| packetBsb.putByte(topicFilterFlags.underlying.toByte) | ||||||
| packetBsb.putByte((topicFilterFlags.underlying >> 1).toByte) | ||||||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 
    
 | 
||||||
| packetBsb.putByte((topicFilterFlags.underlying >> 1).toByte) | |
| packetBsb.putByte(topicFilterFlags.underlying.toByte) | 
    
      
    
      Copilot
AI
    
    
    
      Oct 10, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The QoS decoding is left-shifting by 1 bit, but this appears inconsistent with typical MQTT QoS encoding where QoS values occupy the least significant bits (bits 1-0). If the encoding is right-shifting by 1, then decoding should also right-shift by 1 to extract the QoS from the correct bit positions. The shift directions in encode and decode operations should be inverse operations.
| val topicFilter = (v.decodeString(), ControlPacketFlags((v.getByte << 1) & 0xFF)) | |
| val topicFilter = (v.decodeString(), ControlPacketFlags(v.getByte & 0x03)) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this to a 1.2.x.backward.excludes instead of 1.1.x.backward.excludes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sbmpost could you make this change? We released 1.2.0 a week or 2 ago and now that diff is really with 1.2 as opposed to 1.1