Smack 3.0.4 listeners called for the wrong user - reconnection or concurrency?

I’m working on a server that uses Smack 3.0.4* to connect to GoogleTalk for multiple clients, creating an instance of XMPPConnection per client. The clients are mobile & use an asynchronous API on our server.

We’re seeing sporadic occurrences of problems where:

  1. A message sent by our server from A to B is immediately received by the message listener for A
  2. A’s roster listener methods are called for an entry B who isn’t in A’s roster

These problems are relatively rare; they haven’t occurred in our development environments & until now we haven’t had much time to try to reproduce them, nor have we been able to glean much from the server & its logs when it does occur.

There are probably no more than 10s of concurrent XMPPConnections on the server when this occurs. Recreating the XMPPConnection stops this occurring.

Unless this is a bug in Google’s servers, it seems to me like Smack listeners are getting associated with the wrong connection somehow.

The server logs for #2 show that the ReconnectionManager reconnected the affected connections just prior to the unexpected roster listener call - here, user.two should not be in user.one’s roster:

[ity.xmpp.SmackPresenceListener] {user.one@gmail.com-SPR(155)} [] presenceChanged(unavailable)
[    community.xmpp.XMPPAdapter] {user.one@gmail.com-SPR(155)} [] user.one@gmail.com: connectionClosedOnError: [    community.xmpp.XMPPAdapter] {Smack Reconnection Manager} [] user.one@gmail.com: reconnecting now
[    community.xmpp.XMPPAdapter] {Smack Reconnection Manager} [] user.one@gmail.com: reconnectionSuccessful
[ity.xmpp.SmackPresenceListener] {user.one@gmail.com-SLP(155)} [] entriesAdded([user.two@gmail.com])
[    community.xmpp.XMPPAdapter] {Smack Reconnection Manager} [] user.one@gmail.com: reconnectionSuccessful
[    community.xmpp.XMPPAdapter] {Smack Reconnection Manager} [] user.one@gmail.com: reconnectionSuccessful

SmackPresenceListener is the RosterListener impl and its entriesAdded method does nothing except log, so I’m confident that our listener code isn’t doing the wrong thing.

I don’t have detailed logs for #1 to hand - will add them if I find them.

Changelogs for 3.1.0 & 3.2.0 don’t show anything obviously relevant.

Any suggestions or help on this gratefully received.

*Actually a small patch on 3.0.4 to use log4j and change some thread names