From the Javadocs:
getRoster
> public abstract Roster **getRoster**()
Returns the roster for the user.
This method will never returnnull
, instead if the user has not yet logged into the server or is logged in anonymously all modifying methods of the returned roster object likeRoster.createEntry(String, String, String[])
,Roster.removeEntry(RosterEntry)
, etc. except adding or removingRosterListener
s will throw an IllegalStateException.
Returns:
the user’s roster.
From my code:
try {
connection = new XMPPConnection(config);
Roster roster = connection.getRoster();
if (roster == null) {
LOGGER.severe("Roster is null! THAT'S IMPOSSIBLE!!11!1!");
}
roster.addRosterListener(this);
connection.connect();
connection.login(userName, password);
} catch (XMPPException ex) {
connection = null;
throw new Exception("Failed to establish a connection", ex);
}
Output: Roster is null! THAT’S IMPOSSIBLE!!11!1!
Why?