ably-java icon indicating copy to clipboard operation
ably-java copied to clipboard

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

Open AndyTWF opened this issue 3 years ago • 2 comments

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

AndyTWF avatar Jan 09 '23 17:01 AndyTWF

➤ Automation for Jira commented:

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

sync-by-unito[bot] avatar Jan 09 '23 17:01 sync-by-unito[bot]

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).

AndyTWF avatar Jan 09 '23 18:01 AndyTWF