powered by Jive Software

aSmack-4.0rc1 Roster bug

Hello everyone, found a bug in roster, if you create entry without group method getEntries() returns old values. Same problem was in 8.10.

Users without group:

roster1.createEntry(user2, “videoChatUser2”, null);

roster2.createEntry(user1, “videoChatUser1”, null);

D/Roster﹕ roster1.entriesUpdated 18552-438@chatstage.quickblox.com type=none status=subscribe

D/Roster﹕ roster2.entriesUpdated 18551-438@chatstage.quickblox.com type=none status=subscribe

D/Roster﹕ roster2.entriesUpdated 18551-438@chatstage.quickblox.com type=from status=subscribe

D/Roster﹕ roster1.entriesUpdated 18552-438@chatstage.quickblox.com type=to status=null

D/Roster﹕ roster2.entriesUpdated 18551-438@chatstage.quickblox.com type=both status=null

D/Roster﹕ roster1.entriesUpdated 18552-438@chatstage.quickblox.com type=both status=null

getEntries() and print them:

D/Roster﹕ 18552-438@chatstage.quickblox.com type=none status=null

D/Roster﹕ 18551-438@chatstage.quickblox.com type=none status=null

Users with group:

roster1.createEntry(user2, “videoChatUser2”, new String[]{“group”});

roster2.createEntry(user1, “videoChatUser1”, new String[]{“group”});

D/Roster﹕ roster1.entriesUpdated 18552-438@chatstage.quickblox.com type=none status=subscribe

D/Roster﹕ roster2.entriesUpdated 18551-438@chatstage.quickblox.com type=none status=subscribe

D/Roster﹕ roster2.entriesUpdated 18551-438@chatstage.quickblox.com type=from status=subscribe

D/Roster﹕ roster1.entriesUpdated 18552-438@chatstage.quickblox.com type=to status=null

D/Roster﹕ roster1.entriesUpdated 18552-438@chatstage.quickblox.com type=both status=null

D/Roster﹕ roster2.entriesUpdated 18551-438@chatstage.quickblox.com type=both status=null

getEntries() and print them:

D/Roster﹕ 18552-438@chatstage.quickblox.com type=both status=null

D/Roster﹕ 18551-438@chatstage.quickblox.com type=both status=null

If I get you right, then it’s about the ‘none’ in

getEntries() and print them:

D/Roster﹕ 18552-438@chatstage.quickblox.com none null

D/Roster﹕ 18551-438@chatstage.quickblox.com none null

correct?

I was unable to identity an bug in Smack’s Roster implementation. If createEntry() is called with a group/some groups, then the group names are simply added to the RosterPacket. If groups is not, they are not added.

Most (all?) methods of Roster are asynchronous. Maybe the server doesn’t send the roster pushes some some reason? I think we first have to determine if it’s a client or server bug. A full trace of the exchanged stanzas would be helpful.

The problem is in unfiledEntries collection, it isn’t updated with entries map. So if you changed your entry type from none to both and call getEntries in first case(user don’t have groups) it returns items from unfiledEntries list and in second - items from entries map. And items in unfiledEntries still has none type.

Ohha, that’s an important info. The roster code is quite complex, do you happen to know where exactly the update of the unfiledEntries List is missing?

Unfortunately no, I found it in 8.10 but roster was almost fully rewritten.

It’s likely this:

Roster.java

// Mark the entry as unfiled if it does not belong to any groups.

if (item.getGroupNames().isEmpty()) {

if (!unfiledEntries.contains(entry)) {

unfiledEntries.add(entry);

}

}

The problem is, that RosterEntry’s equals method only checks for the user.

Therefore the unfiledEntries is not updated because it already contains the user, but with another type attribute.

Solution: Always first remove the entry, then re-add it.

The problem may occur on other places, too (haven’t checked). Care must be taken everywhere, where a Collection is used and the equals method of the collection items was overwritten.

SMACK-559, thanks Christian.

aSmack-4.0.0-rc2-SNAPSHOT-2014-04-30 contains the bugfix. Would be great if you could evaluate and report back if it works now.

I couldn’t test the fix, look at http://community.igniterealtime.org/thread/52438.

Hey Igor,

new Snapshots are available. Those should also fix this bug. Would be great if you could verify and report back. Thank you.

Works great, thank you!