sorry for posting as doc before. i’m a new comer to smack, recentely i update asmack from 0.8.10 to smack 4.0.0 rc1, and found 2 problems. pls tell me if i’m wrong, thanks
1> in XMPPConnection.java we have
void callConnectionAuthenticatedListener() {
for (ConnectionListener listener : getConnectionListeners()) {
listener.connected(this);
}
}
and in Roster.java’s we have
connection.addConnectionListener(new AbstractConnectionListener() {
public void authenticated(XMPPConnection connection) {
// Anonymous users can’t have a roster, but it iss possible that a Roster instance is
// retrieved if getRoster() is called before connect(). So we have to check here
// again if it’s an anonymous connection.
if (connection.isAnonymous())
return;
if (!connection.getConfiguration().isRosterLoadedAtLogin())
return;
try {
Roster.this.reload();
}
catch (SmackException e) {
LOGGER.log(Level.SEVERE, “Could not reload Roster”, e);
return;
}
}
});
if we call connection.getRoster() before login(as suggest by http://www.igniterealtime.org/builds/smack/docs/latest/documentation/roster.html), then in Roster.java i’m expecting connection.addConnectionListener is called and wait authenticated event to reload roster, but authenticated() is not called by XMPPConnection at all, so we can’t get any roster
2>in PrivateDataManager.java
private static final Map<XMPPConnection, PrivateDataManager> instances = new WeakHashMap<XMPPConnection, PrivateDataManager>();
public static synchronized PrivateDataManager getInstanceFor(
XMPPConnection connection) {
PrivateDataManager privateDataManager = instances.get(connection);
if (connection == null) {
privateDataManager = new PrivateDataManager(connection);
}
return privateDataManager;
}
if param connection is not null, new PrivateDataManager(connection) will never called. and since “instances” is both static and private, i don’t think there is any other way to fill the date, so PrivateDataManager.getInstanceFor(connection) is always return null. i change " if (connection == null) " to “if(privateDataManager == null)” and it works
so i don’t know if there is sth wroing with my code, or pls confirm whether it’s a bug or not. thank you Flow and all.