PubSub unsubscription could fail with "xmpp.pubsub.multiple-subscriptions=true"

Hi there,

using the OF v4.5.2, i noticed, that PubSub unsubscription could fail, even though it shouldn’t. Let me explain the scenario:

1.allow multiple PubSub subscription by setting:
xmpp.pubsub.multiple-subscriptions=true
2.perform the type “nodes” subscription of particular PubSub node -> you get “sub-id1” in result
3.perform the type “items” subscription of particular PubSub node -> you get “sub-id2” in result
4.perform unsubscription of particular PubSub node and “sub-id1” -> OK
5.perform unsubscription of particular PubSub node and “sub-id2” -> FAIL(“not-subscribed”)

The order of “sub-id1” or “sub-id2” in steps 4. and 5. is irrelevant, the 2nd simply always FAILS.

I got time to analyze the problem and even debug the OF sources and found the problem and solution as well.

The problem is in PubSubEngine.java and method unsubscribeNode() and following line of code
if (node.isMultipleSubscriptionsEnabled() && node.getSubscriptions(owner).size() > 1) {

In step 4, this is true, so the correct subscription is found based on sub-id.
But in step 5, this is false, because node.getSubscriptions(owner).size()==1, so the subscription is tried to be found based on subscriberJID, but this is no longer present as it was already deleted by step 4.

My suggestion would be to remove the check for number of subscriptions and leave just:
if (node.isMultipleSubscriptionsEnabled()) {

It would simply mean, that when multiple subscriptions are allowed, then sub-id MUST always be specified.

Thank you. Please consider submitting a github pull request with your suggested change. The pubsub has changed some since the 4.5.2 release, so the master branch may look different now.

pull request pending…

1 Like

Thanks for your detailed explanation. I’ve merged your PR. It will be part of the 4.6.0 release.

Always happy to help.