Smack v4.4.0-alpha3: MultiUserChat executes callback to userStatusListeners before setting joined = false

Smack v4.4.0-alpha3 executes callback to userStatusListeners before calling userHasLeft() i.e.
setting joined = false. This cause some problem in aTalk. Propose that ‘joined’ status be updated before the userStatusListeners callback is performed.

aTalk performs some local cleanup when the room is destroyed. In which it also do a check on
MultiUserChat.isJoined() and proceed to MultiUserChat.leave() if true, as shown in the below aTalk debug log.

2020-01-19 07:30:02.768 2078-2623/org.atalk.android D/SMACK: RECV (0): 
    <presence to='swordfish@atalk.org/atalk' from='chatroom-y@conference.atalk.org/swordfish' type='unavailable'>
      <x xmlns='http://jabber.org/protocol/muc#user'>
        <destroy jid='chatroom-y@conference.atalk.org'>
          <reason>
            User requested
          </reason>
        </destroy>
        <item role='none' affiliation='none'/>
      </x>
    </presence>
2020-01-19 07:30:02.771 2078-2623/org.atalk.android D/SMACK: RECV (0): 
    <iq xml:lang='en-GB' to='swordfish@atalk.org/atalk' from='chatroom-y@conference.atalk.org' type='result' id='287VL-250'/>
2020-01-19 07:30:02.776 2078-2623/org.atalk.android D/SMACK: RECV (0): 
    <r xmlns='urn:xmpp:sm:3'/>
2020-01-19 07:30:02.777 2078-2622/org.atalk.android D/SMACK: SENT (0): 
    <a xmlns='urn:xmpp:sm:3' h='107'/>
2020-01-19 07:30:02.779 2078-2622/org.atalk.android D/SMACK: SENT (0): 
    <presence to='chatroom-y@conference.atalk.org/swordfish' id='287VL-254' type='unavailable'>
    </presence>
2020-01-19 07:30:02.866 2078-2623/org.atalk.android D/SMACK: RECV (0): 
    <presence xml:lang='en-GB' to='swordfish@atalk.org/atalk' from='chatroom-y@conference.atalk.org/swordfish' type='error' id='287VL-254'>
      <error code='404' type='cancel'>
        <item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
        <text xml:lang='en' xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>
          Conference room does not exist
        </text>
      </error>
    </presence>
2020-01-19 07:30:02.870 2078-2623/org.atalk.android D/SMACK: RECV (0): 
    <r xmlns='urn:xmpp:sm:3'/>
2020-01-19 07:30:02.874 2078-3916/org.atalk.android W/(ChatRoomJabberImpl.java:874)#leave: Error occurred while leaving, maybe just disconnected before leaving
    org.jivesoftware.smack.XMPPException$XMPPErrorException: XMPP error reply received from chatroom-y@conference.atalk.org/swordfish: XMPPError: item-not-found - cancel [Conference room does not exist]
        at org.jivesoftware.smack.StanzaCollector.nextResultOrThrow(StanzaCollector.java:284)
        at org.jivesoftware.smack.StanzaCollector.nextResultOrThrow(StanzaCollector.java:228)
        at org.jivesoftware.smackx.muc.MultiUserChat.leave(MultiUserChat.java:759)
        at net.java.sip.communicator.impl.protocol.jabber.ChatRoomJabberImpl.leave(ChatRoomJabberImpl.java:872)
        at net.java.sip.communicator.impl.protocol.jabber.ChatRoomJabberImpl.access$2600(ChatRoomJabberImpl.java:81)
        at net.java.sip.communicator.impl.protocol.jabber.ChatRoomJabberImpl$ParticipantListener.processOwnPresence(ChatRoomJabberImpl.java:2672)
        at net.java.sip.communicator.impl.protocol.jabber.ChatRoomJabberImpl$ParticipantListener.processPresence(ChatRoomJabberImpl.java:2621)
        at org.jivesoftware.smackx.muc.MultiUserChat$3$1.run(MultiUserChat.java:270)
        at org.jivesoftware.smack.AsyncButOrdered$Handler.run(AsyncButOrdered.java:135)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)

I have not yet looked at the code, but from what I understand reading your post this sounds very sensible. Thanks for the feedback! :slight_smile:

Please see below link for the proposed patch.

This topic was automatically closed 62 days after the last reply. New replies are no longer allowed.