PubSub nonpersistent no payload events are not fireing event listeners on node


When using PubSub and trying to publish events on node that has NO PERSISTENT ITEMS, and event itself has NO PAYLOAD, ItemEventListener#handlePublushedItems does not get triggered.

After looking into the code, listener is listening for “item” element, and that is not persistent in this (perfectly valid) use case scenario.

Is it a bug or required behaviour? Listeners get triggered when I publish empty item to PERSISTENT node - but this is different scenario. It is not possible to publish item to node that is configurated to be not persisted according to XEP-0060, and openfire (right thing) returns error.

PubSubManager man = new PubSubManager(getConnectionForClient(client));
LeafNode node = man.createNode("moderator"); ConfigureForm config = new ConfigureForm(DataForm.Type.submit);
node.addItemEventListener(new ItemEventListener() {    @Override
   public void handlePublishedItems(ItemPublishEvent items) {    log.warn("Got some event: {}", items);
   } }); log.warn("WILL PUBLISH ITEM");
log.warn("ITEM PUBLISHED");
Thread.sleep(100 * 1000);
(100 * 1000);

and the console output.

D/SMACK: SENT (0): <iq to='' id='f9Qqj-16' type='set'><pubsub xmlns=''><subscribe node='moderator' jid=''/></pubsub></iq>
D/SMACK: RECV (0): <iq type="result" id="f9Qqj-16" from="" to=""><pubsub xmlns=""><subscription node="moderator" jid="" subid="YUuj7T14DoYU477PGWSe9Et74fuhU7B5NGxQOuS6" subscription="subscribed"><subscribe-options/></subscription></pubsub></iq>
W/*torEventsReceivingTest: WILL PUBLISH ITEM
W/*torEventsReceivingTest: ITEM PUBLISHED
D/SMACK: SENT (0): <iq to='' id='f9Qqj-18' type='set'><pubsub xmlns=''><publish node='moderator'/></pubsub></iq>
D/SMACK: RECV (0): <iq type="result" id="f9Qqj-18" from="" to=""/>
D/SMACK: RECV (0): <message from="" to="" id="moderator__test.test.te@mydomain.com__2YiL4"><event xmlns=""><items node="moderator"/></event><headers xmlns=""><header name="SubID">YUuj7T14DoYU477PGWSe9Et74fuhU7B5NGxQOuS6</header></headers></message>

You can clearly see that even is not triggered but event itself is delivered to the client

Is it a bug or required behaviour?
Neither. It’s just the current implementation. Patches welcome.

Listeners get triggered when I publish empty item to PERSISTENT node
Which control flow path invokes the listeners in this case?

This is the scenario when set


and publish empty item via

node.publish(new Item()).

Publishing without item is forbidden in this case (compliant with XEP).