Skip to content

Commit 1191172

Browse files
author
Ian Craggs
committed
Stop NPE on unrecognized message id in ack
Bug: 470718
1 parent 1130f00 commit 1191172

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

  • org.eclipse.paho.client.mqttv3/src/main

org.eclipse.paho.client.mqttv3/src/main/java/org/eclipse/paho/client/mqttv3/internal/ClientState.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* Ian Craggs - fix duplicate message id (Bug 466853)
1616
* Ian Craggs - ack control (bug 472172)
1717
* James Sutton - Ping Callback (bug 473928)
18+
* Ian Craggs - fix for NPE bug 470718
1819
*/
1920
package org.eclipse.paho.client.mqttv3.internal;
2021

@@ -859,7 +860,11 @@ protected void notifyReceivedAck(MqttAck ack) throws MqttException {
859860
MqttToken token = tokenStore.getToken(ack);
860861
MqttException mex = null;
861862

862-
if (ack instanceof MqttPubRec) {
863+
if (token == null) {
864+
// @TRACE 662=no message found for ack id={0}
865+
log.fine(CLASS_NAME, methodName, "662", new Object[] {
866+
new Integer(ack.getMessageId())});
867+
} else if (ack instanceof MqttPubRec) {
863868
// Complete the QoS 2 flow. Unlike all other
864869
// flows, QoS is a 2 phase flow. The second phase sends a
865870
// PUBREL - the operation is not complete until a PUBCOMP

org.eclipse.paho.client.mqttv3/src/main/resources/org/eclipse/paho/client/mqttv3/internal/nls/logcat.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
659=start timer for client:{0}
115115
660=Check schedule at {0}
116116
661=stop
117+
662=no message found for ack id={0}
117118
700=stopping
118119
701=notify workAvailable and wait for run
119120
703=stopped

0 commit comments

Comments
 (0)