Closed
Description
I'm pretty sure that there is potential race condition in the following code:
Set<Topic> set = listenerTopics.get(listener);
if (set == null) {
set = new CopyOnWriteArraySet<>();
listenerTopics.put(listener, set);
}
The solution could be to replace it with something like this:
Set<Topic> set = listenerTopics.computeIfAbsent(listener, $ -> new CopyOnWriteArraySet<>());