Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2009, 2018 IBM Corp and others.
* Copyright (c) 2009, 2026 IBM Corp and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
Expand All @@ -19,6 +19,7 @@
* James Sutton - Automatic Reconnect & Offline Buffering
* Jens Reimann - Fix issue #370
* James Sutton - Mqttv5 - Outgoing Topic Aliases
* Harshit Sharma - Fix server Assigned client ID bug
*/
package org.eclipse.paho.mqttv5.client.internal;

Expand Down Expand Up @@ -1058,7 +1059,13 @@ protected void notifyReceivedAck(MqttAck ack) throws MqttException {
int rc = ((MqttConnAck) ack).getReturnCode();
if (rc == 0) {
synchronized (queueLock) {
if (cleanStart) {
// Fix: Don't clear state if server assigned a client ID
// The ConnectActionListener will handle persistence re-initialization
// and clearing after opening with the assigned client ID
MqttConnAck connAck = (MqttConnAck) ack;
Boolean hasAssignedClientId = connAck.getProperties() != null
&& connAck.getProperties().getAssignedClientIdentifier() != null;
if (cleanStart && !hasAssignedClientId) {
clearState();
// Add the connect token back in so that users can be
// notified when connect completes.
Expand Down