diff --git a/source/org/jivesoftware/smack/Roster.java b/source/org/jivesoftware/smack/Roster.java index 196a4c3ea..9a46fb050 100644 --- a/source/org/jivesoftware/smack/Roster.java +++ b/source/org/jivesoftware/smack/Roster.java @@ -440,7 +440,15 @@ public class Roster { * when you are not subscribed to the user's presence updates.
* * If the user has several presences (one for each resource) then answer the presence - * with the highest priority. + * with the highest priority.
+ * + * Note that presence information is received asynchronously. So, just after logging + * in to the server, presence values for users in the roster might be null + * even if they are actually online. In other words, the value returned by this + * method should only be treated as a snapshot in time, and may not accurately reflect + * other user's presence instant by instant. If you need to track presence over time, + * such as when showing a visual representation of the roster, consider using a + * {@link RosterListener}. * * @param user a fully qualified xmpp ID. The address could be in any valid format (e.g. * "domain/resource", "user@domain" or "user@domain/resource"). @@ -552,7 +560,7 @@ public class Roster { */ private void fireRosterChangedEvent(Collection addedEntries, Collection updatedEntries, Collection deletedEntries) { - RosterListener [] listeners = null; + RosterListener [] listeners; synchronized (rosterListeners) { listeners = new RosterListener[rosterListeners.size()]; rosterListeners.toArray(listeners); @@ -574,7 +582,7 @@ public class Roster { * Fires roster presence changed event to roster listeners. */ private void fireRosterPresenceEvent(String user) { - RosterListener [] listeners = null; + RosterListener [] listeners; synchronized (rosterListeners) { listeners = new RosterListener[rosterListeners.size()]; rosterListeners.toArray(listeners); diff --git a/source/org/jivesoftware/smack/RosterListener.java b/source/org/jivesoftware/smack/RosterListener.java index fbc6ce8e7..11f6bcdd3 100644 --- a/source/org/jivesoftware/smack/RosterListener.java +++ b/source/org/jivesoftware/smack/RosterListener.java @@ -25,7 +25,8 @@ import java.util.Collection; /** * A listener that is fired any time a roster is changed or the presence of * a user in the roster is changed. - * + * + * @see Roster#addRosterListener(RosterListener) * @author Matt Tucker */ public interface RosterListener {