You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The MemorySubscriptionsRepository implementation does not synchronise write access to the subscriptions list. As a result, Iterations over the list will break when another Thread modifies the list.
I'm not sure what the best way to solve this is:
the easy way is to use a CopyOnWriteArrayList to protect iterations, and to synchronise add and remove operations. This would not be good for add/remove performance.
Another option is to use a ConcurrentSkipListSet that has better add/remove performance, but that would mean the interface of the public List<Subscription> listAllSubscriptions() method would need to change to return a Set.
What do you think?
I'll make a PR for the change to ConcurrentSkipListSet. The other one is pretty trivial.
Expected behavior
No exceptions
Actual behavior
ConcurrentModificationExceptions in MemorySubscriptionsRepository
Steps to reproduce
Have many clients subscribe and unsubscribe often, while publishes are in progress.
Minimal yet complete reproducer code (or URL to code) or complete log file
…riptionsRepository
The MemorySubscriptionsRepository implementation does not synchronise
write access to the subscriptions list. As a result, Iterations over the
list will break when another Thread modifies the list.
This changes the ArrayList to a ConcurrentSkipListSet and changes the
interface of the public List<Subscription> listAllSubscriptions() method
to return a Set.
hylkevds
added a commit
to FraunhoferIOSB/moquette
that referenced
this issue
Feb 2, 2021
…riptionsRepository
The MemorySubscriptionsRepository implementation does not synchronise
write access to the subscriptions list. As a result, Iterations over the
list will break when another Thread modifies the list.
This changes the ArrayList to a ConcurrentSkipListSet and changes the
interface of the public List<Subscription> listAllSubscriptions() method
to return a Set.
The MemorySubscriptionsRepository implementation does not synchronise write access to the subscriptions list. As a result, Iterations over the list will break when another Thread modifies the list.
I'm not sure what the best way to solve this is:
public List<Subscription> listAllSubscriptions()
method would need to change to return aSet
.What do you think?
I'll make a PR for the change to ConcurrentSkipListSet. The other one is pretty trivial.
Expected behavior
No exceptions
Actual behavior
ConcurrentModificationExceptions in MemorySubscriptionsRepository
Steps to reproduce
Have many clients subscribe and unsubscribe often, while publishes are in progress.
Minimal yet complete reproducer code (or URL to code) or complete log file
Moquette MQTT version
0.14
JVM version (e.g.
java -version
)OpenJDK 11
OS version (e.g.
uname -a
)Linux
The text was updated successfully, but these errors were encountered: