eclipse-paho / eclipse-paho/paho.mqtt.java
ConcurrentModificationException when calling unsubscribe
- Dominant language
- Java
- Stars
- 2.3k
- Forks
- 919
- PR merge metrics
- No merged PRs in 30d
Description
- [x] Bug exists Release Version 1.2.5 ( Master Branch)
- [x] Bug exists in MQTTv3 Client on Snapshot Version 1.2.6-SNAPSHOT (Develop Branch)
- [x] Bug exists in MQTTv5 Client on Snapshot Version 1.2.6-SNAPSHOT (Develop Branch)
When subscribing to topics with a topic specific message listener on the AsyncClient (i.e calling `MqttAsyncClient.subscribe([]MqttSubscription, Object, MqttActionListener, IMqttMessageListener, MqttProperties` an `unsubscribe` later runs into the ConcurrentModifcationException.
This is caused [here](https://github.com/eclipse/paho.mqtt.java/blob/6f35dcb785597a6fd49091efe2dba47513939420/org.eclipse.paho.mqttv5.client/src/main/java/org/eclipse/paho/mqttv5/client/internal/CommsCallback.java#L570) because the the Map is modified (by calling `remove`) without using the iterator.
So when using topic specific subscriptions it doesn't seem possible to unsubscribe right now.
Contributor guide
Assessment
This issue has not been assessed yet.