paho.mqtt.java icon indicating copy to clipboard operation
paho.mqtt.java copied to clipboard

ConcurrentModificationException when calling unsubscribe

Open dereulenspiegel opened this issue 1 year ago • 1 comments

  • [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 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.

dereulenspiegel avatar Mar 01 '23 15:03 dereulenspiegel