GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Include user properties and subscription IDs in MqttProperties#isEmpty by ShadowySpirits · Pull Request #16575 · netty/netty

Include user properties and subscription IDs in MqttProperties#isEmpty #16575

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.

Sign up for GitHub

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

Merged
normanmaurer merged 1 commit into netty:4.2 from ShadowySpirits:fix-mqtt-properties-is-empty
Mar 31, 2026
+68 −1
Merged

Include user properties and subscription IDs in MqttProperties#isEmpty #16575

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1 commit
Select commit
10c96ac
Include user properties and subscription IDs in MqttProperties#isEmpty
ShadowySpirits Mar 30, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

4 changes: 3 additions & 1 deletion 4 codec-mqtt/src/main/java/io/netty/handler/codec/mqtt/MqttProperties.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,9 @@ public Collection<? extends MqttProperty> listAll() {

public boolean isEmpty() {
IntObjectHashMap<MqttProperty> props = this.props;
return props == null || props.isEmpty();
return (props == null || props.isEmpty()) &&
(userProperties == null || userProperties.isEmpty()) &&
(subscriptionIds == null || subscriptionIds.isEmpty());
}

/**
Expand Down
41 changes: 41 additions & 0 deletions 41 codec-mqtt/src/test/java/io/netty/handler/codec/mqtt/MqttCodecTest.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,25 @@ public void testPubAckMessageSkipCodeForMqtt5() throws Exception {
(MqttPubReplyMessageVariableHeader) decodedMessage.variableHeader());
}

@Test
public void testPubAckMessageWithUserPropertyAndSuccessForMqtt5() throws Exception {
when(versionAttrMock.get()).thenReturn(MqttVersion.MQTT_5);

MqttProperties props = new MqttProperties();
props.add(new MqttProperties.UserProperty("traceId", "abc"));
final MqttMessage message = createPubAckMessage((byte) 0, props);
ByteBuf byteBuf = MqttEncoder.doEncode(ctx, message);

mqttDecoder.channelRead(ctx, byteBuf);

assertEquals(1, out.size());

final MqttMessage decodedMessage = (MqttMessage) out.get(0);
validateFixedHeaders(message.fixedHeader(), decodedMessage.fixedHeader());
validatePubReplyVariableHeader((MqttPubReplyMessageVariableHeader) message.variableHeader(),
(MqttPubReplyMessageVariableHeader) decodedMessage.variableHeader());
}

@Test
public void testSubAckMessageForMqtt5() throws Exception {
MqttProperties props = new MqttProperties();
Expand Down Expand Up @@ -810,6 +829,28 @@ public void testDisconnectMessageSkipCodeForMqtt5() throws Exception {
(MqttReasonCodeAndPropertiesVariableHeader) decodedMessage.variableHeader());
}

@Test
public void testDisconnectMessageWithUserPropertyAndSuccessForMqtt5() throws Exception {
when(versionAttrMock.get()).thenReturn(MqttVersion.MQTT_5);

MqttProperties props = new MqttProperties();
props.add(new MqttProperties.UserProperty("traceId", "abc"));
final MqttMessage message = MqttMessageBuilders.disconnect()
.reasonCode((byte) 0)
.properties(props)
.build();
ByteBuf byteBuf = MqttEncoder.doEncode(ctx, message);

mqttDecoder.channelRead(ctx, byteBuf);

assertEquals(1, out.size());
final MqttMessage decodedMessage = (MqttMessage) out.get(0);
validateFixedHeaders(message.fixedHeader(), decodedMessage.fixedHeader());
validateReasonCodeAndPropertiesVariableHeader(
(MqttReasonCodeAndPropertiesVariableHeader) message.variableHeader(),
(MqttReasonCodeAndPropertiesVariableHeader) decodedMessage.variableHeader());
}

@Test
public void testAuthMessageForMqtt5() throws Exception {
when(versionAttrMock.get()).thenReturn(MqttVersion.MQTT_5);
Expand Down
24 changes: 24 additions & 0 deletions 24 codec-mqtt/src/test/java/io/netty/handler/codec/mqtt/MqttPropertiesTest.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import static io.netty.handler.codec.mqtt.MqttProperties.SUBSCRIPTION_IDENTIFIER;
import static io.netty.handler.codec.mqtt.MqttProperties.USER_PROPERTY;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class MqttPropertiesTest {

Expand Down Expand Up @@ -108,4 +110,26 @@ public void testListAll() {
assertEquals(expectedProperties, props.listAll());
}

@Test
public void testIsEmptyWithOnlyUserProperties() {
MqttProperties props = new MqttProperties();

assertTrue(props.isEmpty());

props.add(new MqttProperties.UserProperty("tag", "firstTag"));

assertFalse(props.isEmpty());
}

@Test
public void testIsEmptyWithOnlySubscriptionIdentifiers() {
MqttProperties props = new MqttProperties();

assertTrue(props.isEmpty());

props.add(new MqttProperties.IntegerProperty(SUBSCRIPTION_IDENTIFIER, 10));

assertFalse(props.isEmpty());
}

}
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.