Skip to content

Commit

Permalink
[bidi] [java] Fix the adding and the removing listener
Browse files Browse the repository at this point in the history
  • Loading branch information
pujagani committed Jul 2, 2024
1 parent 48fd956 commit 5c08747
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions java/src/org/openqa/selenium/bidi/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,7 @@ public <X> long addListener(Event<X> event, Consumer<X> handler) {
Lock lock = callbacksLock.writeLock();
lock.lock();
try {
eventCallbacks.computeIfAbsent(
event,
key -> {
HashMap<Long, Consumer<?>> map = new HashMap<>();
map.put(id, handler);
return map;
});
eventCallbacks.computeIfAbsent(event, key -> new HashMap<>()).put(id, handler);
} finally {
lock.unlock();
}
Expand All @@ -217,13 +211,6 @@ public void removeListener(long id) {
lock.lock();
try {
eventCallbacks.forEach((k, v) -> v.remove(id));
eventCallbacks.forEach(
(k, v) -> {
v.remove(id);
if (v.isEmpty()) {
eventCallbacks.remove(k);
}
});
} finally {
lock.unlock();
}
Expand Down

0 comments on commit 5c08747

Please sign in to comment.