[infinispan-issues] [JBoss JIRA] (HRJS-79) Registering listener with undefined listenerId does nothing
Anna Manukyan (Jira)
issues at jboss.org
Thu May 30 07:36:00 EDT 2019
[ https://issues.jboss.org/browse/HRJS-79?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Anna Manukyan updated HRJS-79:
------------------------------
Status: Open (was: New)
> Registering listener with undefined listenerId does nothing
> -----------------------------------------------------------
>
> Key: HRJS-79
> URL: https://issues.jboss.org/browse/HRJS-79
> Project: Infinispan Javascript client
> Issue Type: Bug
> Reporter: Anna Manukyan
> Priority: Major
>
> I was trying the following scenario: the case when the listenerId is passed while adding new listeners.
> I was creating 3 listeners for create,modify and remove events. While adding listeners for modify and remove events I was passing the listenerId, but for modify event the listenerId was some nonexistent string.
> I was curious what will happen. From the functional side nothing happened, so the modify event is not fired and from the logs I can see the following:
> {code}
> [2018-09-25T22:24:55.845] [DEBUG] client - Invoke addListener(msgId=464,event=create,listenerId=listener_465,opts=undefined) remotely
> [2018-09-25T22:24:55.845] [TRACE] encoder - Encode operation with topology id 0
> [2018-09-25T22:24:55.846] [TRACE] listener - Create listener emitter for connection 127.0.0.1:11222 at conn_15 and listener with listenerId=listener_465
> [2018-09-25T22:24:55.846] [TRACE] io_7 - Write buffer(msgId=464) to 127.0.0.1:11222 at conn_15: A0D0031D2500000300010D00010D000C6C697374656E65725F343635000000000F
> [2018-09-25T22:24:55.847] [TRACE] decoder - Read header(msgId=464): opCode=38, status=0, hasNewTopology=0
> [2018-09-25T22:24:55.847] [TRACE] decoder - Call decode for request(msgId=464)
> [2018-09-25T22:24:55.847] [TRACE] io_7_conn_15 - Complete success for request(msgId=464) with true
> [2018-09-25T22:24:55.847] [TRACE] io_7_conn_15 - After decoding request(msgId=464), buffer size is 6, and offset 6
> [2018-09-25T22:24:55.847] [DEBUG] client - Invoke addListener(msgId=466,event=modify,opts={"listenerId":"blblbl"}) locally
> {color:red}[2018-09-25T22:24:55.848] [TRACE] listener - Create listener emitter for connection undefined and listener with listenerId=blblbl{color}
> [2018-09-25T22:24:55.848] [DEBUG] client - Invoke addListener(msgId=467,event=remove,opts={"listenerId":"listener_465"}) locally
> {code}
> So the first line creates "create" event listener remotely. For the "modify" and "delete" events the "addLocalListener()" function is called. I am worried about the line marked in red, there the connection is passed as {color:red}undefined{color}.
> I have found out that the connection parameter is not passed to protocol's addListener function when it is called from addLocalListener() function, but couldn't find a way to fix that.
> Should it be that way?
> I know that this kind of scenario is hardly possible but just in case the developer did some mistake, perhaps he/she may spend much time on finding why the event is not fired.
> The code for generating this log is given here:
> {code}
> ...code in the test...
> it('fails when trying to attach to non-existent listener', function(done) {
> client.then(function (client) {
> var clientAddListenerCreate = client.addListener(
> 'create', function(key) { console.log('[Event] Created key: ' + key); });
> var clientAddListeners = clientAddListenerCreate.then(
> function(listenerId) {
> // Multiple callbacks can be associated with a single client-side listener.
> // This is achieved by registering listeners with the same listener id
> // as shown in the example below.
> var clientAddListenerModify = client.addListener(
> 'modify', function(key) { console.log('[Event] Modified key: ' + key); },
> {listenerId: 'blblbl'});
> var clientAddListenerRemove = client.addListener(
> 'remove', function(key) { console.log('[Event] Removed key: ' + key); },
> {listenerId: listenerId});
> return Promise.all([clientAddListenerModify, clientAddListenerRemove]);
> });
> var clientCreate = clientAddListeners.then(
> function() { return client.putIfAbsent('eventful', 'v0'); });
> var clientModify = clientCreate.then(
> function() { return client.replace('eventful', 'v1'); });
> var clientRemove = clientModify.then(
> function() { return client.remove('eventful'); });
> var clientRemoveListener =
> Promise.all([clientAddListenerCreate, clientRemove]).then(
> function(values) {
> var listenerId = values[0];
> return client.removeListener(listenerId);
> });
> }).catch(t.failed(done)).finally(done);
> });
> ........
> {code}
--
This message was sent by Atlassian Jira
(v7.12.1#712002)
More information about the infinispan-issues
mailing list