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

Hey.

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));
man.deleteNode("moderator");
LeafNode node = man.createNode("moderator"); ConfigureForm config = new ConfigureForm(DataForm.Type.submit);
config.setDeliverPayloads(false);
config.setPersistentItems(false);
config.setAccessModel(AccessModel.open);
config.setNotifyRetract(true);
node.sendConfigurationForm(config);
node.subscribe("test.test.te@mydomain.com");
node.addItemEventListener(new ItemEventListener() {    @Override
   public void handlePublishedItems(ItemPublishEvent items) {    log.warn("Got some event: {}", items);
   } }); log.warn("WILL PUBLISH ITEM");
Thread.sleep(2000);
node.publish();
log.warn("ITEM PUBLISHED");
Thread.sleep(100 * 1000);
(100 * 1000);

and the console output.

D/SMACK: SENT (0): <iq to='pubsub.mydomain.com' id='f9Qqj-16' type='set'><pubsub xmlns='http://jabber.org/protocol/pubsub'><subscribe node='moderator' jid='test.test.te@mydomain.com'/></pubsub></iq>
D/SMACK: RECV (0): <iq type="result" id="f9Qqj-16" from="pubsub.mydomain.com" to="test.test.te@mydomain.com/46333ff8311c4da66bb3465a93a547bb"><pubsub xmlns="http://jabber.org/protocol/pubsub"><subscription node="moderator" jid="test.test.te@mydomain.com" subid="YUuj7T14DoYU477PGWSe9Et74fuhU7B5NGxQOuS6" subscription="subscribed"><subscribe-options/></subscription></pubsub></iq>
W/*torEventsReceivingTest: WILL PUBLISH ITEM
W/*torEventsReceivingTest: ITEM PUBLISHED
D/SMACK: SENT (0): <iq to='pubsub.mydomain.com' id='f9Qqj-18' type='set'><pubsub xmlns='http://jabber.org/protocol/pubsub'><publish node='moderator'/></pubsub></iq>
D/SMACK: RECV (0): <iq type="result" id="f9Qqj-18" from="pubsub.mydomain.com" to="test.test.te@mydomain.com/46333ff8311c4da66bb3465a93a547bb"/>
D/SMACK: RECV (0): <message from="pubsub.mydomain.com" to="test.test.te@mydomain.com" id="moderator__test.test.te@mydomain.com__2YiL4"><event xmlns="http://jabber.org/protocol/pubsub#event"><items node="moderator"/></event><headers xmlns="http://jabber.org/protocol/shim"><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

config.setPersistentItems(true);

and publish empty item via

node.publish(new Item()).

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