Wait in Roster's presence listener until Roster is loaded

Fixes SMACK-681.
This commit is contained in:
Florian Schmaus 2015-07-03 14:24:13 +02:00
parent e6a403fb1c
commit 3bb06b8429
1 changed files with 7 additions and 0 deletions

View File

@ -1180,6 +1180,13 @@ public class Roster extends Manager {
@Override
public void processPacket(Stanza packet) throws NotConnectedException {
// Try to ensure that the roster is loaded when processing presence stanzas. While the
// presence listener is synchronous, the roster result listener is not, which means that
// the presence listener may be invoked with a not yet loaded roster.
boolean loaded = waitUntilLoaded();
if (loaded) {
LOGGER.warning("Roster not loaded while processing presence stanza");
}
final XMPPConnection connection = connection();
Presence presence = (Presence) packet;
String from = presence.getFrom();