Currently listeners list is not synchronized. That means that removing
listener in receive handler causes ConcurrentModificationException to be
thrown.
This patch wraps listeners list with Collections.synchronizedList() and
synchronizes all iteration on it with synchronize(listeners) as
synchornized list requires.
After that it's Ok to unsubscribe from events in receive handlers.
Currently listeners list is not synchronized. That means that removing listener in receive handler causes ConcurrentModificationException to be thrown.
This patch wraps listeners list with Collections.synchronizedList() and synchronizes all iteration on it with synchronize(listeners) as synchornized list requires.
After that it's Ok to unsubscribe from events in receive handlers.