miguelparaz

MultiUserChat: No ServiceDiscoveryManager when reconnecting/ConnectionCreationListener setup

Discussion created by miguelparaz on Oct 13, 2009

Hi,

Scenario:

 

Step 1. Setup

XMPPConnection.connect()

XMPPConnection.addPacketListener() for Message

XMPPConnection.addConnectionListener()

XMPPConnection.login()

new MultiUserChat() for XMPPConnection

MultiUserChat.join()

 

Step 2. Disconnect

MultiUserChat.leave()

XMPPConnection.disconnect()

 

Step 3. Repeat Step 1.

 

 

I get a NullPointerException in line 84:

 

                ServiceDiscoveryManager.getInstanceFor(connection).addFeature(di
scoNamespace);

 

because in ServiceDiscoveryManager, Map<XMPPConnection, ServiceDiscoveryManager> instances is null for the new XMPPConnection,

because in XMPPConnection,   we have:

 

private final static Set<ConnectionCreationListener> connectionEstablishedListeners =

            new CopyOnWriteArraySet<ConnectionCreationListener>();

 

Shouldn't this be non-static so that each XMPPConnection will have its own set of ConnectionCreationListeners?

 

 

I think the code is too dependent on static members.

Thanks.

Outcomes