ably / ably-java

Java, Android, Clojure and Scala client library SDK for Ably realtime messaging service
https://ably.com/download
Apache License 2.0
85 stars 39 forks source link

EventEmitter.on() does not permit the same listener to be added multiple times #888

Open AndyTWF opened 1 year ago

AndyTWF commented 1 year ago

https://github.com/ably/ably-java/blob/9786de65bd44c2f139a53ee235535cb7617cbc87/lib/src/main/java/io/ably/lib/util/EventEmitter.java#L41

The two implementations of EventEmitter.on() prevents the same listener from being registered multiple times (and thus being invoked multiple times per event). It should allow this to happen as per https://sdk.ably.com/builds/ably/specification/main/features/#RTE4.

Furthermore, the implementation of https://github.com/ably/ably-java/blob/9786de65bd44c2f139a53ee235535cb7617cbc87/lib/src/main/java/io/ably/lib/util/EventEmitter.java#L41 means that registering the same listener for different events (e.g. channel attachment, channel detachment) causes the first registration to be replaced with subsequent ones.

┆Issue is synchronized with this Jira Task by Unito

sync-by-unito[bot] commented 1 year ago

➤ Automation for Jira commented:

The link to the corresponding Jira issue is https://ably.atlassian.net/browse/SDK-3224

AndyTWF commented 1 year ago

Opened PR to correct the current documentation in the short term whilst we consider the possible side-effects of fixing the bug (users may be relying on the current implementations incorrect behaviour).