XMPPConnection still ''connected'' when listener''s connectionClosed called

Hello all,

So inside the XMPPConnection.shutdown() method the boolean ‘‘connected’’ (XMPPConnection.isConnected()) is set to ‘‘false’’ at the very end of the method. It may be better to set this to ‘‘false’’ at the beginning of this method, before closing the packet readers and writers?

In many ways it seems sensible to wait until everything is completely closed before setting isConnected to false, however the PacketReader notifies ConnectionListeners during its PacketReader.shutdown() method. And this is called while XMPPConnection.isConnected() is still ‘‘true’’. Thus when ConnectionListener.connectionClosed() is called, XMPPConnection.isConnected() is still true.

E.g.

public void connectionClosed() {

System.out.print(conn.isConnected());

}

Prints ‘‘true’’ when the ConnectionListener is notified after the connection is closed (for example, by the server)

This seems very wrong and in my case is causing some trouble I have to hack around. In the program I’'m working on, I have numerous threads that are awaken during this event, but when they check conn.isConnected(), they get the wrong answer, well at least for a few milliseconds until XMPPConnection.shutdown() completes.

eric

Interesting issue. I think you make a good point about reflecting the closed state when notifying listeners. I’‘ll need to trace through the code to see if this has any side effects. However, I’'ve filed this as SMACK-196.

Thanks,

Matt