Skip to content
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

Made sessionPresent flag settable in ModifiableConnackPacket. #479

Merged
merged 3 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
run: |
git clone https://github.com/hivemq/hivemq-extension-sdk.git ../hivemq-extension-sdk
cd ../hivemq-extension-sdk
git checkout ${GITHUB_REF##*/} || true
git checkout ${GITHUB_REF#refs/heads/} || true
cd ../hivemq-community-edition
- name: Setup Java
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
public class ModifiableConnackPacketImpl implements ModifiableConnackPacket {

private @NotNull ConnackReasonCode reasonCode;
private final boolean sessionPresent;
private boolean sessionPresent;
private final long sessionExpiryInterval;
private final int serverKeepAlive;
private @Nullable String assignedClientId;
Expand Down Expand Up @@ -158,6 +158,16 @@ public void setAssignedClientIdentifier(final @Nullable String assignedClientIde
modified = true;
}

@Override
public void setSessionPresent(final boolean sessionPresent) {
if (Objects.equals(this.sessionPresent, sessionPresent)) {
return;
}

this.sessionPresent = sessionPresent;
modified = true;
}

@Override
public @NotNull Optional<String> getAuthenticationMethod() {
return Optional.ofNullable(authenticationMethod);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -763,4 +763,36 @@ public void copy_changes() {
UserPropertiesImpl.of(ImmutableList.of(new MqttUserProperty("testName", "testValue"))));
assertEquals(expectedPacket, copy);
}

@Test
public void setSessionPresent() {
final ConnackPacketImpl packet = new ConnackPacketImpl(ConnackReasonCode.UNSPECIFIED_ERROR,
true,
10,
60,
null,
null,
null,
3,
1000,
10,
Qos.AT_LEAST_ONCE,
true,
true,
true,
true,
null,
null,
null,
UserPropertiesImpl.of(ImmutableList.of()));
final ModifiableConnackPacketImpl modifiablePacket =
new ModifiableConnackPacketImpl(packet, configurationService, true);

assertFalse(modifiablePacket.isModified());

modifiablePacket.setSessionPresent(false);

assertTrue(modifiablePacket.isModified());
assertFalse(modifiablePacket.getSessionPresent());
}
}