We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5c08747 commit 06e7b7aCopy full SHA for 06e7b7a
java/src/org/openqa/selenium/bidi/Connection.java
@@ -25,6 +25,7 @@
25
import java.io.Closeable;
26
import java.io.StringReader;
27
import java.time.Duration;
28
+import java.util.ArrayList;
29
import java.util.HashMap;
30
import java.util.List;
31
import java.util.Map;
@@ -210,7 +211,16 @@ public void removeListener(long id) {
210
211
Lock lock = callbacksLock.writeLock();
212
lock.lock();
213
try {
- eventCallbacks.forEach((k, v) -> v.remove(id));
214
+ List<Event<?>> list = new ArrayList<>();
215
+ eventCallbacks.forEach(
216
+ (k, v) -> {
217
+ v.remove(id);
218
+ if (v.isEmpty()) {
219
+ list.add(k);
220
+ }
221
+ });
222
+
223
+ list.forEach(eventCallbacks::remove);
224
} finally {
225
lock.unlock();
226
}
0 commit comments