[muc] Bookmarks.getConferenceStorage() don't parse empty <nick/> #617
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For a conference a server may return empty element.
This will cause an exception on parsing and the whole conference won't appear in a client. A similar problem will occur if something wrong with the nick format. The nick in a conference is optional thing, and we are safe to ignore any problems with it. In this case a default account JID must be used.
Strictly speaking this change may potentially cause NPE in other places. I found that there are some checks for the Nickname to be empty in the
org/jivesoftware/smackx/muc/bookmarkautojoin/MucBookmarkAutojoinManager.java:125
:The second place where the getNickname() is called is a serialization method
toXML
and I made it not to print the<nick>null</nick>
element.So I hope no one will be affected by the change or at least the problem will be now better localized.
I do have the problem IRL:
So here I joined a conference
[email protected]
from my account[email protected]
from Gajim. It looks like I didn't specified my nickname and on the server it was set to empty.The XEP-0402 says that the whole
nick
element is optional. This is an issue of the XEP that didn't clearly specified this and an XMPP server that it mustn't return the empty nick element. Both 404.city and conversations.im use latest ejaberd and I'll report a corresponding bug there. UPD processone/ejabberd#4272Still we need this check in the Smack to avoid problems with old versions and other badly implemented servers.