powered by Jive Software

NullPointerException when user joins MUC


#1

I am currently using Smack version 4.3.1 and building an Android application.

When creating a MUC I use the following

MultiUserChatManager mucManager = MultiUserChatManager.getInstanceFor(mConnection);
                        MultiUserChat muc = mucManager.getMultiUserChat(JidCreate.entityBareFrom(uniqueId + Constants.CHAT_MUC_RESOURCE_PREFIX + mConnection.getUser().asBareJid().getDomain().toString()));
                        Resourcepart nickname = Resourcepart.from(mConnection.getUser().asBareJid().toString());

                        muc.create(nickname);

                        Form form = muc.getConfigurationForm();
                        Form submitForm = form.createAnswerForm();

                        for (FormField formField : form.getFields()) {
                            submitForm.setDefaultAnswer(formField.getVariable());
                        }

                        muc.sendConfigurationForm(submitForm);
                        muc.addMessageListener(this);

                        for (String jid : jidList) {
                            muc.invite(JidCreate.entityBareFrom(jid), "");
                        }

It creates a MUC just fine and will send out invites. User’s using the same version connecting via other Xmpp connections other than Smack can join just fine and Smack can handle it but when a user joins from an older version of Smack the app crashes with the following stacktrace. This happens with MultiUserChat.java tries to handle the presence of the user joining.

New Fatal Issue - MultiUserChat.java line 226 - Android com.nightly SNAPSHOT-20190430 (15566843

 --------- beginning of crash
05-01 13:59:47.965 11806-1395/com.android.nightly E/AndroidRuntime: FATAL EXCEPTION: Smack Cached Executor
Process: com.android.nightly, PID: 11806
java.lang.NullPointerException: Attempt to invoke virtual method 'org.jivesoftware.smackx.muc.MUCAffiliation org.jivesoftware.smackx.muc.packet.MUCItem.getAffiliation()' on a null object reference
at org.jivesoftware.smackx.muc.MultiUserChat$3$1.run(MultiUserChat.java:226)
at org.jivesoftware.smack.AsyncButOrdered$Handler.run(AsyncButOrdered.java:121)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:762)

We cannot update the Smack version of the other app since we do not have ownership over it.

Any help on how to handle this would be much appreciated! Thank you.


#2

Is there any other information that I might be able to give to get some help on this?


#3

Yes: The stanza that is causing this. My guess is that it is an presence without muc#user.

See also https://github.com/igniterealtime/Smack/wiki/How-to-ask-for-help,-report-an-issue-and-possible-solve-the-problem-yourself


#4

I apologize…

Here’s the stanza that’s causing it. It looks like there’s two muc#user extension and Smack is just pulling the first one.

<presence xmlns='jabber:client' to='tojid@test.im' from='jwg6z4o5c9bbxdsutu571gopfinxm7@muc.domain.im/fromUserNickname' id='skCD7-58'>
	<priority>0</priority>
	<x xmlns='http://jabber.org/protocol/muc#user'></x>
	<x xmlns='http://jabber.org/protocol/muc#user'>
		<item affiliation='none' jid='fromJid@test.im' nick='fromJid@test.im' role='participant'>
			
		</item>
	</x>
	<x xmlns='urn:xmpp:SERVER:userinfo' xmlns:stream='http://etherx.jabber.org/streams'>
		<firstname xmlns:stream='http://etherx.jabber.org/streams'>First</firstname>
		<lastname xmlns:stream='http://etherx.jabber.org/streams'>Last</lastname>
	</x>
</presence>

#5

That looks like something you want to report to the vendor if the MUC service implementation.

But Smack should not crash. This is possibly an oversight in the implementation. I’ll look into it.


#6

Created SMACK-896.